Can I rely on a manifold stream as a response to a web request to behave as a delay (meaning no execution of its content until it is realized after being handled by middleware)?
I'm wanting to write auth middleware which relies on this property and enforces authentication/authorization after the response is being passed back up the middleware chain, rather than checking auth before the handler is reached.
I have been running into issues with compojure where if I try to handle auth in middleware as the request is coming in, it will end up enforcing auth even if the request didn't match any of the routes I was trying to implement auth for.
This could be resolved by using #reitit instead which has per-route middleware
But if I delay checking auth until after a handler returns something (so I know a route was matched), then the handler has already executed the contents regardless of if the user were authenticated/authorized.