io.aviso.rook.arg-resolvers

added in 0.2.2

Built-in implementations and support functions for argument resolver generators.

default-arg-resolvers

Defines the following argument resolvers:

:request
The argument resolves to a key in the :request map.
An exception is thrown if the resolved value is nil.
:path-param
The argument resolves to a path parameter.
An exception is thrown if the resolved value is nil.
:query-param
The argument resolves to a query parameter, as applied by the default io.pedestal.http.route/query-params interceptor.
:form-param
As :query-param, but for the encoded form parameters. Assumes the necessary middleware to process the body into form parameters and keywordize the keys is present.

For these resolvers if the meta data value is exactly the value true (e.g., just using ^:request), then the effective value is a keyword generated from the parameter symbol.

inject-resolver

(inject-resolver meta-key injections)

For a given meta-data key and map of injections, returns an arg-resolver generator, wrapped in a map that can be merged with default-arg-resolvers.

Parameters are converted to keys into the injections map. The injections map should use keyword keys.

Will throw an exception if a parameter symbol fails to match a non-nil value in the injections map.

meta-value-for-parameter

(meta-value-for-parameter sym meta-key)

Given a parameter symbol and a metadata key, returns the value for that metadata key.

It is presumed that the value is a keyword, though no check is made.

When the metadata value is explicitly true, the symbol is converted into a simple (not namespaced) keyword.

non-nil-arg-resolver

(non-nil-arg-resolver sym ks)

Returns an arg resolver that extracts a value nested in the context.

The value must be non-nil, or an exception is thrown.

sym
The symbol for which the argument resolver was created; identified in the exception.
ks
a sequence of keys.

standard-arg-resolver

(standard-arg-resolver ks)

Returns an arg resolver that extracts a value nested in the context.

ks
A sequence of keys.