1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.RedirectRoute = void 0;
|
8 | class RedirectRoute {
|
9 | constructor(sourcePath, targetLocation, statusCode = 303) {
|
10 | this.sourcePath = sourcePath;
|
11 | this.targetLocation = targetLocation;
|
12 | this.statusCode = statusCode;
|
13 |
|
14 | this.pathParams = [];
|
15 | this.schemas = {};
|
16 |
|
17 | this.verb = 'get';
|
18 | this.spec = {
|
19 | description: 'LoopBack Redirect route',
|
20 | 'x-visibility': 'undocumented',
|
21 | responses: {},
|
22 | };
|
23 | this.path = sourcePath;
|
24 | }
|
25 | async invokeHandler({ response }, args) {
|
26 | response.redirect(this.statusCode, this.targetLocation);
|
27 | }
|
28 | updateBindings(requestContext) {
|
29 |
|
30 | }
|
31 | describe() {
|
32 | return `Redirect: "${this.sourcePath}" => "${this.targetLocation}"`;
|
33 | }
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | static isRedirectRoute(obj) {
|
40 | var _a;
|
41 | const redirectOptions = obj;
|
42 | if ((redirectOptions === null || redirectOptions === void 0 ? void 0 : redirectOptions.targetLocation) &&
|
43 | ((_a = redirectOptions.spec) === null || _a === void 0 ? void 0 : _a.description) === 'LoopBack Redirect route') {
|
44 | return true;
|
45 | }
|
46 | return false;
|
47 | }
|
48 | }
|
49 | exports.RedirectRoute = RedirectRoute;
|
50 |
|
\ | No newline at end of file |