reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
paulbutcher 2021-01-28T11:32:01.014800Z

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 Deobald 2021-01-28T21:47:18.016100Z

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 Deobald 2021-01-28T21:48:27.017300Z

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 Deobald 2021-01-28T21:51:41.018Z

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 Deobald 2021-01-28T23:59:38.021400Z

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: https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj