UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
3// Node module: @loopback/rest
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.Route = void 0;
8const core_1 = require("@loopback/core");
9const keys_1 = require("../keys");
10const base_route_1 = require("./base-route");
11class Route extends base_route_1.BaseRoute {
12 constructor(verb, path, spec, _handler) {
13 super(verb, path, spec);
14 this.spec = spec;
15 this._handler = _handler;
16 }
17 describe() {
18 return `${super.describe()} => ${this._handler.name || this._handler.toString()}`;
19 }
20 updateBindings(requestContext) {
21 requestContext.bind(keys_1.RestBindings.OPERATION_SPEC_CURRENT).to(this.spec);
22 }
23 async invokeHandler(requestContext, args) {
24 // Use `invokeMethodWithInterceptors` to invoke the handler function so
25 // that global interceptors are applied
26 return (0, core_1.invokeMethodWithInterceptors)(requestContext, this, '_handler', args, { source: new base_route_1.RouteSource(this) });
27 }
28}
29exports.Route = Route;
30//# sourceMappingURL=handler-route.js.map
\No newline at end of file