Conditional Ring middleware, which allows conditional execution of Ring middleware paths. Includes convenience methods for common cases.
Conditional Ring middleware, which allows conditional execution of Ring middleware paths. Includes convenience methods for common cases.
(if f pred middleware)
Basic conditional Ring middleware. For each request, invokes (pred request).
If the result is truthy, the request is passed to the 'middleware' handler. Otherwise, ignores 'middleware' and continues down the stack.
For example: (def app (-> base-handler (ring.middleware.conditional/if some-fn? wrap-with-logging) wrap-with-stuff))
will always run wrap-with-stuff's handler and base-handler, but will skip wrap-with-logging when (some-fn? request) is true.
Basic conditional Ring middleware. For each request, invokes (pred request). If the result is truthy, the request is passed to the 'middleware' handler. Otherwise, ignores 'middleware' and continues down the stack. For example: (def app (-> base-handler (ring.middleware.conditional/if some-fn? wrap-with-logging) wrap-with-stuff)) will always run wrap-with-stuff's handler and base-handler, but will skip wrap-with-logging when (some-fn? request) is true.
(if-url-doesnt-match f regex middleware)
Convenience method that invokes the given Ring middleware if the URI in the request does NOT match the provided regex.
Convenience method that invokes the given Ring middleware if the URI in the request does NOT match the provided regex.
(if-url-doesnt-start-with f strs middleware)
Convenience method that invokes the given Ring middleware if the URI in the request does NOT start with the provided literal string. Takes a single path or a collection of paths as a fn argument
Convenience method that invokes the given Ring middleware if the URI in the request does NOT start with the provided literal string. Takes a single path or a collection of paths as a fn argument
(if-url-matches f regex middleware)
Convenience method that invokes the given Ring middleware if the URI in the request matches the provided regex.
Convenience method that invokes the given Ring middleware if the URI in the request matches the provided regex.
(if-url-starts-with f strs middleware)
Convenience method that invokes the given Ring middleware if the URI in the request starts with the provided literal string. Takes a single path or a collection of paths as a fn argument
Convenience method that invokes the given Ring middleware if the URI in the request starts with the provided literal string. Takes a single path or a collection of paths as a fn argument
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close