More controllable composition of Ring middlewares.
This library is attempt to resolve following difficulties with usage of Ring middlewares:
-> macro what makes hard to reason about
actual request/response flow between wrappers.Ring handlers are build from handler function and sequence of middleware configurations using handler/build function.
Default type of ring handler is sync handler. To produce async ring handler
use either :async option or {:async true} in handler's meta.
Every middleware configuration is a map with keys:
{:keys [wrap]}
:wrap – a function (fn [handler] new-handler) to wrap handler.{:keys [enter leave]}
:enter — a function (fn [request] new-request) to transform request.:leave – a function (fn [response request] new-response) to transform
response.Maps with :wrap and :enter/:leave causes exception.
Only middlewares with :wrap can short-circuit, :enter/:leave just modify
request/response.
The middlewares are applied in the order:
:wrap/:enter
middlewares only.:leave/:wrap receives response from next middlewares.See also walkthrough.
TODO
Can you improve this documentation? These fine people already did:
Sergey Trofimov & seriogaEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |