sibiro.params

ERPERIMENTAL! EVERYTHING IS SUBJECT TO CHANGE IN THIS NAMESPACE!

defmethodp

macro

(defmethodp name dispatch bindings & body)
Same as `(defmethod name dispatch [req]
(with-params bindings req body))`.

defnp

macro

(defnp name & body)
Same as `(def name (fnp bindings body))`. Supports docstring,
attribute map, and metadata on the name symbol.

defnp-

macro

(defnp- name & body)
Same as `defnp`, but private.

fnp

macro

(fnp bindings & body)
Same as `(fn [req] (with-params bindings req body))`

with-params

macro

(with-params bindings reqsym & body)
Macro binding the given symbols around the body to the
corresponding values in :route-params or :params (both keyword as
string lookup) from the request. There are also some special keywords
available:

- Prepending a symbol with :as will bind that symbol with the entire
request. Instead of a symbol, a destructuring expression can also be
specified.

- Prepending a map with :or defines default values. If no default
value is specified, and the binding cannot be found in the request
parameters, an exception is thrown. It basically asserts for you
that all parameters are found or at least have a value.

For example:

(fn [req]
  (with-params [name email password
                :or {name "Anonymous"}
                :as {:keys [uri]}] req
    ...))