Fork me on GitHub

I’m trying to wire up my luminus app to support immutant/undertow graceful-shutdown, but having no luck


the change is small, only core.clj is affected so far:


-                      (assoc :handler (handler/app))
+                      (assoc :handler (-> (handler/app) http-handler (graceful-shutdown 60000)))


where http-handler and graceful-shutdown both come from immutant.web.undertow


Can I ask a web dev noob question here? I'm working with sending JSON strings from a chrome app writting in JA to a server app based on the luminus template (running http-kit and with mongodb and cjls options on the template), and I'm having a few strugs with data formats. I have a JSON object of the form {"content": "some_text", "url": "some_text"} being sent by my chrome extension using javascript's JSON.stringify(), via a put request, with content-type application/json; charset=UTF-8, being sent to the /upload endpoint of my app. It seems to be showing up in the body field of the request. When I define the endpoint as (POST "/upload" request (:body request)) and then send it back to the chrome extension to .log it, I just get back a string of the original json data, as expected. However, when I give it (POST "/upload" request (:url (:body request))) it returns a 404 error (??). The puzzle here is that I'm using the default ring.middleware.format wrappers, with {:formats [:json-kw :transit-json :transit-msgpack]} --- so I had thought that ring would be kind enough to just parse out the JSON object I sent it and turn it into a nice native clojure data structure with keywords that I can extract...


I suppose I could always hack my way around the problem, e.g., by eval-ing it and all the rest, but...


or just use data.json myself. but isn't ring supposed to handle that? or am I just confused...


it appears, after a little poking around, that I can get at the content of a key in the json map I've sent like the following, using ( as json):

(defn mapify [weird-json-bytes]
   (json/read-str (slurp weird-json-bytes) :key-fn keyword))

(defroutes home-routes
  (POST "/upload" request (str (:url (mapify (:body request))))))
This feels like a total hack to me... there's gotta be a different way, right?