amelinium.http.middleware.populators
added in 1.0.0
amelinium service, context map population middleware.
compile
(compile data config)
Prepares population map an a basis of configuration sequence by processing its elements.
If the element is a map, it will look for :id
and either :fn
or :compile
keys. The first should be a keyword (a populator ID used as a key when injecting value to a request map), the :fn
should be a populator function or an ident (will be dereferenced), and the :compile
should be a function (or an ident naming the function) which should return a populator. The compiling function will receive a value as an argument which will be a map containing route data.
If the element is a sequence, the first element should be an identifier (a populator ID used as a key when injecting value to a request map) and the second should be a population function or an ident naming the function.
If the element is a single value it should be a string or an ident naming the population function.
compile-populator
(compile-populator data to-enable to-disable entry)
Prepares a single populator.
populate
(populate req populators)
For each populator map calls the function identified by map’s value and associates its result in a request with the key it’s identified by. Called function must accept two arguments (a request/context map and a key) and return a value to be associated.