Fork me on GitHub
#duct
<
2018-05-02
>
ddrbt09:05:01

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?

ddrbt09:05:42

I see there's a key in /api called :duct.middleware.web/format. Can I add that to my /site config?

jahson09:05:03

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.

ddrbt10:05:15

Perfect! thanks @jahson

ddrbt10:05:49

@myguidingstar, I stumbled across that and was trying to adapt it to my config 🙂