Fork me on GitHub

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.


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


: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.


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


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


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.


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)


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 H16:10:33

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 H07:10:43

@U055NJ5CC Your help is much appriciated


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


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


or you could extend reitit: • create a new mw which adds a :post-handler route data key, with a value of a fn of type response -> reaponse • you can use :compile keys to make it good: read the :post-handler at router creation time and return a mw that executes the handler in return phase. If that doesn't exist, do not mount the mw • add a :spec key to mw to document the new key • add the new mw into chain • add a :post-handler key to routes, it is run after the coercion • as route data accumulates, you can put :post-handler anywhere in the route tree and all endpoints under it have that hope this helps.


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


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


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