Fork me on GitHub

Can someone help me with best practice around handling routing errors in frontend code? I’m particularly thinking about cases where: • The user enters a non-existent route • Parameter coercion fails There doesn’t seem to be an equivalent of reitit.ring.middleware.exception for frontend code? What’s the best way to detect and handle these kinds of errors?

Steven Deobald21:01:18

Does the middleware chain have access to :path-params anywhere? Or will routing (and therefore path parsing) always happen after all middleware has been processed?

Steven Deobald21:01:27

I'm asking because I'm currently using Ring middleware (converting everything to using the reitit middleware chain is on my todo list) and it seems like accessing :path-params is impossible from anywhere in the Ring middleware mudball.

Steven Deobald21:01:41

It seems like this should work if I just switch to the reitit mw chain? I should theoretically just need to put the middleware which needs to see :path-params after parameters-middleware?

Steven Deobald23:01:38

I'm taking a stab at this but reitit.ring.middleware.multipart/multipart-middleware doesn't appear to just work out of the box; for some reason, after switching the 2015-style many-nested-ring-middlewares to reitit's vector, my multipart params are empty on POST. I have :parameters :multipart set and I'm using reitit.ring.middleware.parameters/parameters-middleware. I'm not using any other reitit middleware yet, since the multipart-middleware docs don't mention that I'd require any. I can see from the example project that maybe I need some of the muuntaja and/or coercion middleware to make the multipart middleware behave as expected? Looking at this: