Use case: developing a website which serves several ClojureScript-rich pages, which communicate to web services via AJAX.
=> this induces the need for a configuration which exposes both site-style (à la :duct.module.web/site) and API-style (à la :duct.module.web/api) routes.
In particular, site handlers and API handlers require different middleware stacks, e.g a site requires an HTML-based "Not found" / "stacktrace" response, whereas an API will want to encode that in a data format like Transit or JSON; likewise, an API will want to perform content-type negotiation, whereas a site usually only serves HTML.
The Duct template provides no defaults for this (at the time of writing, lein new duct my-website +site +api is not supported, although it does not throw an error), and I'm not even sure it's possible to achieve via duct.module.web, which seems to affect config globally - making it impossible for 2 strategies to cohabitate. For instance, even creating 3 :duct.core/handler-derived keys (one API, one site, and one root) as in this Gist will not work as is, because the whole middleware stack gets added in 3 all places.
Use case: developing a website which serves several ClojureScript-rich pages, which communicate to web services via AJAX.
=> this induces the need for a configuration which exposes both site-style (à la
:duct.module.web/site
) and API-style (à la:duct.module.web/api
) routes.In particular, site handlers and API handlers require different middleware stacks, e.g a site requires an HTML-based "Not found" / "stacktrace" response, whereas an API will want to encode that in a data format like Transit or JSON; likewise, an API will want to perform content-type negotiation, whereas a site usually only serves HTML.
The Duct template provides no defaults for this (at the time of writing,
lein new duct my-website +site +api
is not supported, although it does not throw an error), and I'm not even sure it's possible to achieve viaduct.module.web
, which seems to affect config globally - making it impossible for 2 strategies to cohabitate. For instance, even creating 3:duct.core/handler
-derived keys (one API, one site, and one root) as in this Gist will not work as is, because the whole middleware stack gets added in 3 all places.