Fork me on GitHub
#reitit
<
2020-07-30
>
wegi10:07:37

Hi there. If i have a frontend route foo/:some-id where the browser is currently pointed to and I want to navigate to foo/:some-id/bar is there any way, that reitit can be configured to just keep the same :some-id without me having to specify it for push-state?

worlds-endless21:07:52

Would this work?

worlds-endless21:07:46

Seems like you should be able to get it off the path params here

wegi06:07:19

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.

wegi06:07:00

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

worlds-endless21:07:20

Back-end, Compojure-style. Suppose I have "/foo" {:get myfn} and it is covered by a middleware, but I want the :post on it to have different middleware (or one less middleware). How do I get these different profiles?

miikka07:07:46

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

miikka07:07:53

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

miikka07:07:09

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)