This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-30
Channels
- # admin-announcements (4)
- # alda (49)
- # beginners (42)
- # boot (55)
- # cider (33)
- # cljs-dev (4)
- # cljsjs (3)
- # cljsrn (152)
- # clojure (92)
- # clojure-belgium (3)
- # clojure-brasil (18)
- # clojure-dusseldorf (32)
- # clojure-france (2)
- # clojure-greece (10)
- # clojure-japan (1)
- # clojure-mexico (1)
- # clojure-russia (50)
- # clojure-sg (1)
- # clojure-spain (1)
- # clojure-spec (12)
- # clojurescript (262)
- # core-async (2)
- # cursive (7)
- # datomic (79)
- # emacs (16)
- # euroclojure (2)
- # events (1)
- # hoplon (260)
- # jobs (2)
- # jobs-discuss (1)
- # keechma (7)
- # luminus (8)
- # mount (7)
- # off-topic (3)
- # om (101)
- # onyx (33)
- # re-frame (34)
- # reagent (10)
- # slack-help (4)
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 (clojure.data.json 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?