Hi there.. I have a noob question about wiring up middleware in a duct app. Any chance this is the right place to ask? I want to wrap every request with this flash middleware: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/middleware/flash.clj. I thought adding it like this would do (in my base config):
:duct.handler/root {:middleware [
;; other middlewares...
#ig/ref :my.flash.middleware
]}
where :my.flash.middleware
is just this:
(defmethod ig/init-key :my.flash.middleware/flash [_ _]
#(rf/wrap-flash %))
.. but it doesn't work. Manually wrapping handlers with wrap-flash
appears to work, but I'm struggling to get it wired up for every request.I'm hoping there's just something simple misconfigured.
I remember something about the a namespace named middleware
being treated specially, so this may not be the right answer. Have you tried referring to the whole key like #ig/ref :my.flash.middleware/flash
? (I believe that would also have to be a top level key like :my.flash.middleware/flash {}
)
I think the wrong key version is correct.
Ah interesting. Thanks for the idea.. I'll give it a shot.
Hmm no luck.. I'm wondering if some other middleware is interfering, maybe clobbering the session or something.
you might be in println debugging territory. or can you set a breakpoint? If so you could make a defn just for the purpose of setting a breakpoint.
Hmm boo. Will head down that path. But yeah I should be able to run the site with breakpoints.
You should also try to print the config, it should be availabe from the dev
ns
the issue was that this ring flash middleware was already included in the defaults for our app :woman-facepalming:
So calling it twice caused problems. Very stupid oversight.. anyway, all set now.