compojure

How can I use ring anti-forgery / CSRF token with latest version ring/compojure?

血红的双手。 提交于 2019-12-07 01:27:25
问题 I copied some old code that was working in compojure 1.1.18 and other old libs, but using the latest versions I can't get it to work. Here's my minimal example code copied from the minimal example here to demonstrate that with latest ring and compojure libraries, I get an error when I send an http POST , even with the header set. lein ring server to start it, then do curl -X GET --cookie-jar cookies "http://localhost:3000/" which results in something like this: {"csrf-token":"7JnNbzx8BNG

Optional query parameters (with default value) with compojure-api

一笑奈何 提交于 2019-12-06 18:31:40
问题 What is the proper way to declare an optional query parameter, with default value, when using compojure-api? One of my route elements is as follows (after reading this): (GET "/:id/descendants" [id] :return [d/CategoryTreeElement] :path-params [id :- Long] :query-params [context-type :- d/ContextType levels :- Integer {tenant :- d/Tenant :DEF_TENANT} {show-future :- Boolean false} {show-expired :- Boolean false} {show-suppressed :- Boolean false} :summary "Fetch category descendants" (ok ...)

http request from Google App Engine

笑着哭i 提交于 2019-12-06 08:35:41
I'm trying to make http requests from my Google App Engine webapp, and discovered I have to use URLConnection since it's the only whitelisted class. The corresponding Clojure library is clojure.contrib.http.agent, and my code is as follows: (defroutes example (GET "/" [] (http/string (http/http-agent "http://www.example.com"))) (route/not-found "Page not found")) This works fine in my development environment- the browser displays the text for example.com. But when I test it out with Google's development app server: phrygian:example wei$ dev_appserver.sh war 2010-09-28 14:53:36.120 java[43845

Using Clojure with Vaadin

拥有回忆 提交于 2019-12-05 13:28:45
问题 Has anyone tried implementing a web application with Clojure ( using Compojure ) and Vaadin ? I had seen an article on using Clojure with JWT for creating web apps. Vaadin is based on GWT so you get a lot of the advantages of GWT ( though Vaadin is completely Server-centric). And Clojure gives the advantage that you can use any Java Based Framework, so what thoughts on the Clojure + Vaadin based web application ? 回答1: I've created an article in Vaadin Trac wiki describing such integration:

Compojure handler friend/authenticate eats body of POST request

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:55:35
How can I safely get the content of the :body InputStream from compojure? See related but different question for background. I'm trying to authenticate my ring routes with Friend using compojure handler/site but when I try to read the :body from an http POST request (which is a Java InputStream ), it is closed: 23:01:20.505 ERROR [io.undertow.request] (XNIO-1 task-3) Undertow request failed HttpServerExchange{ POST /paypal/ipn} java.io.IOException: UT000034: Stream is closed at io.undertow.io.UndertowInputStream.read(UndertowInputStream.java:84) ~[undertow-core-1.1.0.Final.jar:1.1.0.Final] at

No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil

女生的网名这么多〃 提交于 2019-12-05 09:53:44
I'm very new to Clojure and I'm having a great time playing with it. One thing I'm having some trouble with is how to read the errors, I personally think they're not very descriptive, but that's probably due to my "newbieness". For example, the issue I'm having now is when I try to start up my ring server (I can provide more details if needed): Started server on port 3000 java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil core_deftype.clj:544 clojure.core/-cache-protocol-fn io.clj:69 clojure.java.io/fn[fn]

How to serve the stream pdf with ring

我只是一个虾纸丫 提交于 2019-12-05 05:52:53
I'm trying to serve a clj-http generated document directly via ring/compojure. I thought ring.util/piped-output-stream would work, but it seems I'm not understanding something here... This: (defn laminat-pdf-t [natno] (piped-input-stream (fn [output-stream]) (pdf [ {:title (str "Omanimali-Kuscheltierpass" natno) :orientation :landscape :size :a6 :author "Omanimali - Stefanie Tuschen" :register-system-fonts true } ;; [:svg {} (clojure.java.io/file ;; (str "/einbuergern/" natno "/svg" ))] [:paragraph "Some Text"] ] output-stream))) (defn laminat-pdf "generate individualized cuddly toy passport

How can I use ring anti-forgery / CSRF token with latest version ring/compojure?

陌路散爱 提交于 2019-12-05 04:19:30
I copied some old code that was working in compojure 1.1.18 and other old libs, but using the latest versions I can't get it to work. Here's my minimal example code copied from the minimal example here to demonstrate that with latest ring and compojure libraries, I get an error when I send an http POST , even with the header set. lein ring server to start it, then do curl -X GET --cookie-jar cookies "http://localhost:3000/" which results in something like this: {"csrf-token":"7JnNbzx8BNG/kAeH4bz1jDdGc7zPC4TddDyiyPGX3jmpVilhyXJ7AOjfJgeQllGthFeVS/rgG4GpkUaF"} But when I do this curl -X POST -v -

Optional query parameters (with default value) with compojure-api

狂风中的少年 提交于 2019-12-04 23:45:32
What is the proper way to declare an optional query parameter, with default value, when using compojure-api ? One of my route elements is as follows (after reading this ): (GET "/:id/descendants" [id] :return [d/CategoryTreeElement] :path-params [id :- Long] :query-params [context-type :- d/ContextType levels :- Integer {tenant :- d/Tenant :DEF_TENANT} {show-future :- Boolean false} {show-expired :- Boolean false} {show-suppressed :- Boolean false} :summary "Fetch category descendants" (ok ...)) At first the boolean params where defined as the other ones (e.g. show-future Boolean ) but the

Limiting the number of threads Compojure spawns

爷,独闯天下 提交于 2019-12-04 19:30:54
I'm running compojure on Heroku. They have a limit of a 100 threads per process. So when I go over that limit, I get: java.lang.OutOfMemoryError: unable to create new native thread. Compojure is using the jetty ring adapter. Is there away of configuring the the server to only accept a hundred threads to the servlet at a time? The solution comes from Chris Perkins over at the compojure google group . (run-jetty app {:configurator #(.setThreadPool % (QueuedThreadPool. 5))}) This initializes a QueuedThreadPool (with a concurrent limit of five threads) to the jetty instance, before it starts. 来源: