Interface: WebFilter
@divine/web-service.WebFilter
The instance side of a web filter.
Filters are used to modify or enhance the behaviour of resources.
Implemented by
Methods
filter
▸ filter(next
, args
, resource
): Promise
<WebResponses
>
Invoked by WebService when the filter should process a request or response.
The filter may act on the request before or after a resource handles the request (or both). Call the next
function to process the request normally and receive the default response. It's also possible to get a reference
to the actual resource instance by calling the resource
function. Note that this function may throw a
WebError in case no resource matched the request.
The filter is free to modify the request, the resource instance and/or the response as part of its work.
Parameters
Name | Type | Description |
---|---|---|
next | () => Promise <WebResponse > | A function that evaluates the request and returns the default response. |
args | WebArguments | The request arguments. |
resource | () => Promise <WebResource > | A function that returns the resource that this request matched. |
Returns
Promise
<WebResponses
>