1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const Server_1 = require("../Server");
|
7 | const bytes_1 = __importDefault(require("bytes"));
|
8 | const debug_1 = require("../../debug");
|
9 | const AbstractMiddleware_1 = require("./AbstractMiddleware");
|
10 | const debug = debug_1.createDebugLogger('middleware:request');
|
11 | class RequestMiddleware extends AbstractMiddleware_1.AbstractMiddleware {
|
12 | async pass(ctx, next) {
|
13 | debug(`<-- ${ctx.method.toUpperCase()} ${ctx.path}`);
|
14 | await next();
|
15 | const response = ctx.state.response;
|
16 | await response.patchContext(ctx);
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | if (ctx.method === Server_1.RequestMethods.Head) {
|
26 | delete ctx.body;
|
27 | }
|
28 | debug(`--> ${ctx.method.toUpperCase()} ${ctx.path} ${response.getStatusCode()} ${bytes_1.default(ctx.length)}`);
|
29 | }
|
30 | }
|
31 | exports.RequestMiddleware = RequestMiddleware;
|
32 |
|
\ | No newline at end of file |