So I'm using Reitit together with Schema for validation, and I want a subset of my routes to return a generic 404 page rather than the validation error when given bad inputs. How can I make this happen?
@wombawomba you can mount an custom exception handling middleware for those routes: catch the coercion error and return 404 instead.
@ikitommi sounds good, thanks.. how would I do that again? 🙂
thanks!
how do I add middleware to a collection of 'flat' routes? I want to do something like the following, but I can't get it to work:
(reitit.ring/router
[[""
{:middleware [my-middleware]}
["/foo" {...}]
["/bar" {...}]]
["/api"
...]])
oh okay, that actually works, it's just that my middleware ends up in the wrong end of the middleware stack
how do I get it to go before the schema validation?
would I need to add a transform to the router?
okay yeah doing that worked 🙂