This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-04
Channels
- # arachne (2)
- # bangalore-clj (3)
- # beginners (34)
- # boot (22)
- # cider (1)
- # cljs-dev (86)
- # cljsjs (3)
- # clojure (42)
- # clojure-argentina (6)
- # clojure-austin (10)
- # clojure-chicago (1)
- # clojure-france (3)
- # clojure-russia (135)
- # clojure-spain (1)
- # clojure-uk (4)
- # clojurescript (69)
- # core-async (13)
- # cursive (11)
- # datascript (6)
- # datomic (8)
- # dirac (2)
- # emacs (10)
- # euroclojure (1)
- # events (1)
- # gsoc (13)
- # jobs-rus (9)
- # lumo (7)
- # off-topic (18)
- # om (16)
- # perun (3)
- # planck (1)
- # portland-or (1)
- # re-frame (25)
- # ring (22)
- # spacemacs (1)
- # untangled (14)
@weavejester True. I ended up using ring.middleware.basic-authentication
@talexxx There's an amazing amount of middleware out there and it takes a while to navigate. I came to Clojure webs from a different tech where there was a lot of core built-in functionality and at first I thought I needed to write a lot of code myself... but as I read more about Ring and looked deeper into the middleware ecosystem, I found nearly everything was already available somewhere and just needed to be composed.
Since then we've written our own middleware for a variety of things (such as New Relic transaction monitoring) and anything that is "common" across parts of our application.
You'd need to write a coercion function for that.
so you'd write (GET "/ticker_:key" [key :<< from-json] my/handler)
and from-json
would parse JSON and produce either a data structure or nil
if parsing failed ^ @isaac
Thanks @seancorfield , I think compojure can not customize boundary of binding pattern, is it?
Not sure what you mean?
Oh, I see... so you have /ticker_SOMETHING_json
and you want the SOMETHING
part?
Hmm, that's tricky... I just simply wouldn't define an end point like that 🙂
/ticket/THING/json
would be my preference
Sorry 🙂
Is there a limited set of things that key
can be?
If so, define all those routes to map to a single function that picks apart (:uri req)
and "does the right thing".
Otherwise /ticker_:key
and map that to a handler and pick {X}_json
apart dynamically...
It might be an interesting enhancement to routes tho', to accept :{thing}
... you might consider a Pull Request to add that to Compojure?