org.dthume.ring.middleware.prefer
Ring middleware providing RFC7240 (Prefer Header for HTTP) support.
Most users will only need to add wrap-prefer to their middleware stack, although prefer-request and prefer-response may be useful for Pedestal interceptors.
parse-prefer-header
(parse-prefer-header v)
Parse one or more Prefer
headers into a map of preference names to Preference
instances.
prefer-request
(prefer-request request)
Apply RFC 7240 handling to request
map.
Prefer
request headers will be parsed into Preference
record instances and added to the request map under the key :prefer
as a map of preference name -> Preference
.
prefer-response
(prefer-response response)
Apply RFC 7240 handling to response
map.
The response map may contain a :prefer
key, whose value may be a single Preference
instance, a map with Preference
values, or collection of Preference
instances. These preferences will be used to add Preference-Applied
headers to the response map.
preference
(preference name)
(preference name stringValueOrParamMap)
(preference name value params)
Construct a Preference
, with mandatory name
and an optional value
and / or paramMap
. Preference
records have three keys:
name
- The name of the preference.
value
- The primary value of the preference, or
nil
if there is none. params
- A map of any secondary parameters specified by the preference.
preference?
(preference? p)
Return true
iff p
is a Preference
record instance.
wrap-prefer
(wrap-prefer handler)
Wrap handler
with middleware for dealing with RFC 7240 preference headers in both request and response maps. See prefer-request and prefer-response for more details on request / response handling.