reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
wegi 2020-07-31T06:54:19.391700Z

Yeah, path-params are viable for that. Can I somehow access them out of the routes definition? For example get the params of the currently set route.

wegi 2020-07-31T06:56:00.391900Z

Just found I could use match-by-path and then extract the coerced parameters.

miikka 2020-07-31T07:03:46.392100Z

Hmm, you could use ^:replace for middleware, although it's not that handy f you just want to remove one middleware.

"/foo" {:get myfn, :post {:handler otherfn, :middleware ^:replace [[wrap-middleware1] [wrap-middleware2]]}
https://cljdoc.org/d/metosin/reitit/0.5.5/doc/basics/route-data#nested-route-data

miikka 2020-07-31T07:04:53.392500Z

So normally if you specify :middleware for :post, the nesting appends it to the middleware you've defined above, but with :replace it instead replaces the middleware stack

miikka 2020-07-31T07:07:09.392700Z

If these are middleware written by you, well, I often solve this by adding a way to disable the middleware with route data, like the first example here https://cljdoc.org/d/metosin/reitit/0.5.5/doc/ring/compiling-middleware#require-keys-on-routes-at-creation-time (so if the route does not have :authorize, the authorization middleware is not mounted)

Empperi 2020-07-31T09:22:49.393600Z

Hi. I wonder if there is a ready-made coercer for Reitit for coercing snake_case keys into kebab-case?

Empperi 2020-07-31T09:22:55.393800Z

Like built-in?

Empperi 2020-07-31T09:23:14.394100Z

I guess it shouldn't be too hard to write myself, just curious