ronda.routing.middleware

compile-endpoints

(compile-endpoints handlers)
Create a Ring handler that intercepts all requests that had an endpoint ID
determined by `wrap-routing` and routes them to the matching handler in the
given handlers map. If no match is found, `nil` is returned.

conditional-middleware

(conditional-middleware handler p? wrap-fn)
Apply the given middleware only if the request matches the given predicate.

conditional-transform

(conditional-transform handler p? f)
Apply the given transformation function to the request, only if it matches
the given predicate.

endpoint-middleware

(endpoint-middleware handler endpoints wrap-fn)
Like `conditional-middleware`, applying the given middleware only if the
request is being routed to one of the given endpoints. (A single
non-sequential endpoint ID may be given instead of a seq of multiple.)

endpoint-transform

(endpoint-transform handler endpoints f)
Like `conditional-transform`, applying the given function to requests
that are being routed to one of the given endpoints. (A single non-sequential
endpoint ID may be given instead of a seq of multiple.)

wrap-endpoint

(wrap-endpoint default-handler endpoint-id handler)
Create a Ring handler that intercepts all requests that had the given
endpoint ID determined by `wrap-routing`, delegating them to the given
handler.

wrap-endpoints

(wrap-endpoints default-handler handlers)
Create a Ring handler that intercepts all requests that had an endpoint ID
determined by `wrap-routing` and routes them to the matching handler in
the given handlers map. If no match is found, the request is passed to the
given default handler.

wrap-routing

(wrap-routing handler descriptor & [{:keys [response?], :or {response? false}}])
Wrap the given Ring handler with middleware-based routing using the given
RouteDescriptor. If a route can be found for a request the descriptor,
route params and endpoint ID are injected into the request map which is then
passed to the original handler. If no route can be found, the request is passed
to the handler unaltered.

If `:response?` is set to `true` in the optional options map, routing
metadata and descriptor is attached to the response, as well.