forest.middleware
Macros that help defining a Forest middlewares. A middleware is a function that receives an app followed by an optional list of arguments.
defmiddleware
macro
(defmiddleware name doc-string? attr-map? middleware-args & body)
Defines a generic middleware that will take an app and do something to change it.
defmiddleware-after
macro
(defmiddleware-after name doc-string? attr-map? middleware-args main-function)
Like defmiddleware
but main-function
will be executed after the request handler.
defmiddleware-around
macro
(defmiddleware-around name doc-string? attr-map? middleware-args main-function)
Like defmiddleware
but main-function
will be executed in place of the request handler. Unlike in defmiddleware
, this main-function
will be passed four arguments: request
, response
, opts
and next
. next
is a function that takes no arguments and will trigger the route’s request handler when being called.
defmiddleware-before
macro
(defmiddleware-before name doc-string? attr-map? middleware-args main-function)
Defines a Forest before
middleware.
main-function
is a function that receives two arguments request
and response
and will be executed before the route’s appropriate request handler.
If main-function
retuns false
, the request handler will be terminated.