Dear all - I have a ring/router that looks like
(ring/router
routes
{:exception pretty/exception
:conflicts nil
:data {:coercion ...
:muuntaja m/instance
:middleware middleware}})
I always had the impression that :middleware and :coercion keys on the route itself would override the "global" ones
(def routes [["/post" {:post {:summary "create"
:coercion coercion/humanized-coercion-options
:middleware (middleware/humanized-middleware state)
...])
Is that the correct position - am I missing something?Thanks @joel.kaasinen that's eventually what I did.
Yeah, conditional middleware based on route data is the pattern I'd recommend with reitit. When you use middleware compilation, the non-active middleware disappears completely at runtime.
Reading this, it seems to imply that the order is top to bottom, i.e., global first, then more specific later:
(i.e., All the middlewares are applied correctly:)
But you can reverse it:
yeah there does not seem to be a way to "override" - I ended up working on a conditional middleware for exceptions
enabled by a boolean in the route data