comment adjustments
This commit is contained in:
parent
096fd8fad5
commit
bd8c88d0d4
|
@ -1,4 +1,5 @@
|
||||||
(ns clj-webtoolbox.routes.checked
|
(ns clj-webtoolbox.routes.checked
|
||||||
|
"Functions and macros to assist with writing more declarative Compojure route validations."
|
||||||
(:require
|
(:require
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[compojure.core :refer [routing]]
|
[compojure.core :refer [routing]]
|
||||||
|
@ -30,13 +31,14 @@
|
||||||
(response/status 500)))
|
(response/status 500)))
|
||||||
|
|
||||||
(defmacro checked-routes
|
(defmacro checked-routes
|
||||||
"Wraps a handler (e.g. subset of routes) with one or more filters ('checks') which
|
"Wraps a handler (e.g. subset of routes) with one or more filters (aka 'checks' or
|
||||||
are run before to handler is run. If any of the filters return nil, fail-response
|
'validations') which are run before to handler is run. If any of the filters return
|
||||||
is returned by the server instead of running the wrapped handler. Filter functions
|
nil, fail-response is returned by the server instead of running the wrapped handler.
|
||||||
should accept a Ring request as the first argument and return a Ring request map
|
Filter functions should accept a Ring request as the first argument and return a
|
||||||
if the filter logic passed. The same Ring request map is threaded through all of
|
Ring request map if the filter logic passed. The same Ring request map is threaded
|
||||||
the filters before eventually being passed on to the handler. If a failure
|
through all of the filters before eventually being passed on to the handler. If a
|
||||||
response is not specified via :on-fail, then a default HTTP 500 response is used."
|
failure response is not specified via :on-fail, then a default HTTP 500 response
|
||||||
|
is used."
|
||||||
{:arglists '([checks & body]
|
{:arglists '([checks & body]
|
||||||
[checks :on-fail fail-response & body])}
|
[checks :on-fail fail-response & body])}
|
||||||
[checks & body]
|
[checks & body]
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
(defmacro routefn
|
(defmacro routefn
|
||||||
"The final form present in a checked-route call. The forms in body are executed
|
"The final form present in a checked-route call. The forms in body are executed
|
||||||
only if none of the previous filters failed. The arguments vector is destructured
|
only if none of the previous filters failed. The arguments vector is destructured
|
||||||
the same was as normal Compojure route parameter destructuring is done, except
|
the same way as normal Compojure route parameter destructuring is done, except
|
||||||
that parameters come from the request's :safe-params map instead."
|
that parameters come from the request's :safe-params map instead."
|
||||||
[request args & body]
|
[request args & body]
|
||||||
(if (vector? args)
|
(if (vector? args)
|
||||||
|
|
Reference in a new issue