Fork me on GitHub
#ring-swagger
<
2018-04-12
>
twashing00:04:08

How would I disable middleware (in metosin/compojure-api), for nested routes. For example, how do we remove parent-middleware application for the “child” context. In this case, I just want the child-middleware.

(context "parent" []
  :middleware [parent-middleware]
  ...
  (context "child" []
    :middleware [child-middleware]
    ...))

twashing02:04:49

So taking this a bit further, I was going through the source of composure.api.integration-test, and it seems that having nested :middleware definitions, is additive. http://metosin.github.io/compojure-api/doc/index.html

twashing02:04:45

Does anyone know if there’s any way in compojure-api api documentation (declaratively or programmatically), that let’s you reset middlewares?

ikitommi09:04:13

@twashing currently, there is no easy way, as it's based on Compojure and routing trees are programs and mw are applied in place.

ikitommi09:04:43

with metosin/reitit, it would be easy:

["/parent" {:middleware [parent-middleware]}
 ["/child {:middleware ^:replace [child-middleware]}]]

twashing16:04:36

@ikitommi Hmm, very interesting. Thanks for the context. That helps a lot.