Page Contents
Home > @loopback/express > toInterceptor
toInterceptor() function
Wrap an express middleware handler function as an interceptor
Signature:
export declare function toInterceptor<CTX extends Context = InvocationContext>(firstHandler: ExpressRequestHandler, ...additionalHandlers: ExpressRequestHandler[]): GenericInterceptor<CTX>;
Parameters
Parameter | Type | Description |
---|---|---|
firstHandler | ExpressRequestHandler | An Express middleware handler |
additionalHandlers | ExpressRequestHandler[] | A list of Express middleware handler function |
Returns:
GenericInterceptor<CTX>
Example
toInterceptor(fn);
toInterceptor(fn1, fn2, fn3);