@adonisjs/http-server 5.10.0 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,7 +31,9 @@ declare module '@ioc:Adonis/Core/HttpContext' {
|
|
|
31
31
|
response: ResponseContract;
|
|
32
32
|
logger: LoggerContract;
|
|
33
33
|
profiler: ProfilerRowContract;
|
|
34
|
-
route?: RouteNode
|
|
34
|
+
route?: RouteNode & {
|
|
35
|
+
params: string[];
|
|
36
|
+
};
|
|
35
37
|
routeKey: string;
|
|
36
38
|
params: Record<string, any>;
|
|
37
39
|
subdomains: Record<string, any>;
|
|
@@ -68,7 +68,9 @@ export declare class HttpContext extends Macroable implements HttpContextContrac
|
|
|
68
68
|
* Reference to the current route. Not available inside
|
|
69
69
|
* server hooks
|
|
70
70
|
*/
|
|
71
|
-
route?: RouteNode
|
|
71
|
+
route?: RouteNode & {
|
|
72
|
+
params: string[];
|
|
73
|
+
};
|
|
72
74
|
/**
|
|
73
75
|
* Required by macroable
|
|
74
76
|
*/
|
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
* For the full copyright and license information, please view the LICENSE
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
9
|
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
10
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
14
|
exports.HttpContext = void 0;
|
|
12
15
|
/// <reference path="../../adonis-typings/index.ts" />
|
|
13
16
|
const net_1 = require("net");
|
|
14
17
|
const util_1 = require("util");
|
|
15
18
|
const macroable_1 = require("macroable");
|
|
19
|
+
const matchit_1 = __importDefault(require("@poppinss/matchit"));
|
|
16
20
|
const utils_1 = require("@poppinss/utils");
|
|
17
21
|
const http_1 = require("http");
|
|
18
22
|
const Request_1 = require("../Request");
|
|
@@ -149,11 +153,15 @@ class HttpContext extends macroable_1.Macroable {
|
|
|
149
153
|
middleware: [],
|
|
150
154
|
handler: async () => 'handled',
|
|
151
155
|
meta: {},
|
|
156
|
+
params: matchit_1.default
|
|
157
|
+
.parse(routePattern, {})
|
|
158
|
+
.filter((token) => [1, 3].includes(token.type))
|
|
159
|
+
.map((token) => token.val),
|
|
152
160
|
};
|
|
153
161
|
/*
|
|
154
162
|
* Defining route key
|
|
155
163
|
*/
|
|
156
|
-
ctx.routeKey = `${request.method()}-${ctx.route.pattern}`;
|
|
164
|
+
ctx.routeKey = `${request.method() || 'GET'}-${ctx.route.pattern}`;
|
|
157
165
|
/*
|
|
158
166
|
* Attaching params to the ctx
|
|
159
167
|
*/
|