reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
seqable 2020-10-27T01:35:36.195300Z

Bit confused about getting frontend to leave anchor links alone.

Precicate to check if the anchor click event default action
should be ignored. This logic will ignore the event
if anchor href matches the route tree, and in this case
the page location is updated using History API.

seqable 2020-10-27T01:44:03.196800Z

but using ignore-anchor-click? all my anchor links just take me to a blank page instead of navigating on-page to where they should. Have replaced them with scroll-to events instead which is ok but seems a bit silly

seqable 2020-10-27T09:54:36.200300Z

:ignore-anchor-click? (constantly true) did the trick, but still a bit confused then on the purpose of the included pred - why'd one ever want to let reitit start a navigation event and suppress on-page nav when there's no router match but an anchor is available? Seems nonintuitive, might be wise to have docs clarify a bit there.

juhoteperi 2020-10-27T10:59:39.201Z

@joen.tolgraven As the docs say, it will only affect anchors which match the route tree.

seqable 2020-10-27T11:01:26.202Z

that was not my experience. If it did that would've made total sense!

juhoteperi 2020-10-27T11:03:30.203700Z

That's how it is written, though bugs are possible. But if is ignoring the default handler, you should see the on-navigate call and the match from the handled anchor.

juhoteperi 2020-10-27T11:04:19.204400Z

If the match is nil and on-navigate is called something is broken, if match is not empty, your route tree is somehow matching the anchor (not-found route or something)

seqable 2020-10-27T11:18:25.206700Z

Cheers, bug makes a lot more sense yeah. Have since changed route tree and can't replicate with current setup, will have a look back later. Match wasn't nil but :name was. No fallback routes. Will try investigate

Eyal H 2020-10-27T16:23:33.210Z

Hey, I'm using the coerce-response-middleware middleware to validate the response returning from the API. My question is as follows: • I'm doing some logic which is related to the response I'm returning in the :handler endpoint • I want to be able to do this logic after the coerce-response-middleware is happening, to be sure that the response is valid How do I accomplish that?

Eyal H 2020-10-28T07:13:43.211300Z

@ikitommi Your help is much appriciated

ikitommi 2020-10-30T16:05:56.220500Z

@eyaldocs no default way to do that, as response coercion happens in mw chain after handler has returned

ikitommi 2020-10-30T16:06:34.220700Z

you could add a custom mw into the chain before the response-coercion to do that

ikitommi 2020-10-30T16:14:57.221200Z

["/api" {:get {:handler ..., :post-handler (fn [res] ....log the data... res)}]

ikitommi 2020-10-30T16:15:50.221400Z

you could also make the :post-handler accept a vector of fns and compose those using comp

2020-10-27T16:36:11.211Z

Is there a way to add field level documentation, like a summary key on the params themselves?