The handler is a function. At the very least it should have a ...
argument
and it must return eiter TRUE
or FALSE
. Returning TRUE
means that the
request is allowed to continue processing and can be passed on to the next
route in the stack. Returning FALSE
stops the processing of the request by
the stack.
While any arguments besides ...
are optional, there are a few that will get
passed in named:
request
will hold the request as a reqres::Request object
response
will hold the request as a reqres::Response object
keys
will be a named list containing the values of the matched path keys
(see example)
Further, if routr is used as a fiery plugin, the handler will receive:
server
is the fiery::Fire
object defining the app
id
is the id of the client sending the request, as provided by fiery
arg_list
is a list of values as calculated by the servers before-request
event handlers
Any and all of the above can be ignored by your handler, but accepting the
server
is often paramount to more powerful features such as delayed
execution or logging.