MCPcopy
hub / github.com/loopbackio/loopback-next / Route

Class Route

packages/rest/src/router/handler-route.ts:12–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10import {BaseRoute, RouteSource} from './base-route';
11
12export class Route extends BaseRoute {
13 constructor(
14 verb: string,
15 path: string,
16 public readonly spec: OperationObject,
17 protected readonly _handler: Function,
18 ) {
19 super(verb, path, spec);
20 }
21
22 describe(): string {
23 return `${super.describe()} => ${
24 this._handler.name || this._handler.toString()
25 }`;
26 }
27
28 updateBindings(requestContext: Context) {
29 requestContext.bind(RestBindings.OPERATION_SPEC_CURRENT).to(this.spec);
30 }
31
32 async invokeHandler(
33 requestContext: Context,
34 args: OperationArgs,
35 ): Promise<OperationRetval> {
36 // Use `invokeMethodWithInterceptors` to invoke the handler function so
37 // that global interceptors are applied
38 return invokeMethodWithInterceptors(
39 requestContext,
40 this,
41 '_handler',
42 args,
43 {source: new RouteSource(this)},
44 );
45 }
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected