This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-22
Channels
- # adventofcode (37)
- # beginners (74)
- # boot (2)
- # boot-dev (31)
- # cider (88)
- # clara (109)
- # cljs-dev (63)
- # clojure (96)
- # clojure-argentina (1)
- # clojure-czech (1)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-germany (3)
- # clojure-greece (2)
- # clojure-italy (5)
- # clojure-norway (1)
- # clojure-spain (1)
- # clojure-spec (25)
- # clojure-uk (46)
- # clojurescript (26)
- # cursive (19)
- # data-science (5)
- # docs (2)
- # duct (18)
- # editors (2)
- # emacs (3)
- # figwheel (2)
- # fulcro (29)
- # graphql (3)
- # hoplon (143)
- # juxt (7)
- # klipse (1)
- # leiningen (5)
- # lumo (1)
- # monads (1)
- # off-topic (23)
- # onyx (49)
- # powderkeg (6)
- # re-frame (4)
- # reagent (8)
- # ring (3)
- # shadow-cljs (24)
- # specter (70)
- # sql (1)
- # unrepl (96)
- # yada (3)
So I have a pretty basic question… I have :duct.module.web/site {}
in my config.edn
, but I want to define many handlers that return JSON. I assume there's some way to declare that a handler should return JSON in config.edn
without me having to do JSON conversion in the handler explicitly, but I can't seem to figure out how to do that.
I’ve had the same issue, not sure how to do it, but know that @weavejester has mentioned that he is looking at a site
+ api
web module. I’m waiting for that
@flowthing: Not sure there’s support for that just yet… You can do something like this:
but the config is going to get unmanageable without writing a module to help make the pain go away
but there could already be a way to do it that I don’t know about
@rickmoynihan: Thanks! I'll give that a shot when I get the chance.
You might want a module that takes a list of handlers and wraps them with the given middleware… there might be something in duct.web to do this already though
not sure
@flowthing: Actually it looks like duct might have support already https://github.com/duct-framework/module.web/blob/master/src/duct/module/web.clj#L139
though if you have two sets of middlewares i.e. if you want both :site
and :api
I think that might not be possible… they’ll probably stomp each other.
yeah I think the problem is they use the same :middleware
key
I think a module that let you wrap your own middlewares over specific handlers would be a good thing.
i.e. a module that would work on something like this: