This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-02
Channels
- # beginners (26)
- # bitcoin (1)
- # boot (9)
- # boot-dev (5)
- # cider (26)
- # cljs-dev (1)
- # clojure (190)
- # clojure-finland (1)
- # clojure-italy (42)
- # clojure-nl (20)
- # clojure-russia (3)
- # clojure-sanfrancisco (1)
- # clojure-serbia (1)
- # clojure-spec (50)
- # clojure-uk (16)
- # clojurescript (62)
- # core-async (4)
- # cryogen (1)
- # cursive (6)
- # datascript (1)
- # datomic (36)
- # duct (6)
- # editors (6)
- # emacs (14)
- # graphql (3)
- # leiningen (30)
- # off-topic (21)
- # om (7)
- # parinfer (13)
- # portkey (56)
- # re-frame (2)
- # reagent (2)
- # shadow-cljs (58)
- # vim (1)
- # yada (3)
I have a duct app using module.web
. How can I use the duct.module.web/site
defaults, but add the content negotiation that comes with duct.module.web/api
?
I see there's a key in /api
called :duct.middleware.web/format
. Can I add that to my /site
config?
quote from @weavejester
The +site profile hint uses the :duct.module.web/site module, while the +api hint uses :duct.module.web/api.
The difference between the two modules is essentially in what middleware they add, and how the middleware is configured. An SPA would sit somewhere between the two.
I plan to write a dedicated :duct.module.web/spamodule soon. In the meantime, the best configuration would probably be to start with the site middleware, then add the content-negotiation middleware from the api middleware. So:
:duct.module.web/site {}
:duct.core/handler
{:middleware [#ig/ref :duct.middleware.web/format]}
:duct.middleware.web/format {}
If you're curious about the exact differences, you can try using both modules, then running (pprint config) in the REPL to see exactly what keys the modules add.
@ddrbt that's exactly what I was trying to do here https://github.com/walkable-server/walkable/blob/master/dev/resources/walkable_demo/config.edn#L15
@myguidingstar, I stumbled across that and was trying to adapt it to my config 🙂