Skip to main content

Class: WebFilterBase<Context>

@divine/web-service.WebFilterBase

An optional, trivial base class for filters, which simply stores a reference to the context and request arguments.

Type parameters

NameDescription
ContextThe type of the WebService context.

Implements

Constructors

constructor

new WebFilterBase<Context>(_context, _args)

Constructs a resource or filter instance.

Type parameters

Name
Context

Parameters

NameTypeDescription
_contextContextThe WebService context.
_argsWebArgumentsThe request arguments.

Defined in

web-service/src/resource.ts:73

Properties

_args

Protected _args: WebArguments

The request arguments.

Defined in

web-service/src/resource.ts:73


_context

Protected _context: Context

The WebService context.

Defined in

web-service/src/resource.ts:73

Methods

filter

Abstract 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

NameTypeDescription
next() => Promise<WebResponse>A function that evaluates the request and returns the default response.
argsWebArgumentsThe request arguments.
resource() => Promise<WebResource>A function that returns the resource that this request matched.

Returns

Promise<WebResponses>

Implementation of

WebFilter.filter

Defined in

web-service/src/resource.ts:77