Creates RestRserveMiddleware object.
RestRserveMiddleware is a very useful concept which allows to perform pre-processing of requests and
post-processing of responses. Middleware has an access to both request and response objects
and can modify them. This way each request can be checked/modified before passing hadnler and response can be
post processed (for example this way we developer can set up custom error messages).
process_request and process_response functions should
return forward() or RestRserveResponse. In the former scenario request, response
will be passed further to subsequent middleware/handlers. In the later scenario the normal flow will be
immediately interrupter and result of the function will be returned as response.
RestRserveMiddlewareR6Class object.
app = RestRserveMiddleware$new(
process_request = function(request, response) forward(),
process_response = function(request, response) forward(),
name = NULL
)
For usage details see Methods, Arguments and Examples sections.
function which takes 2 arguments - request and response
objects (class RestRserveRequest and RestRserveResponse correspondingly) and returns
forward() or RestRserveResponse. Function is called before request is routed to handler.
Usually process_request is used to perform logging, check authorization, etc.
function which takes 2 arguments - request and response
objects (of class RestRserveRequest, and RestRserveResponse correspondingly) and returns
forward() or RestRserveResponse. Function is called after request is processed by handler.
Usually process_response is used to perform logging, custom error hadnling, etc.