deno.land / x / deno@v1.28.2 / cli / bench / testdata / npm / hono / dist / request.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.extendRequestPrototype = void 0;const body_1 = require("./utils/body");const cookie_1 = require("./utils/cookie");function extendRequestPrototype() { if (!!Request.prototype.param) { // already extended return; } Request.prototype.param = function (key) { if (this.paramData) { if (key) { return this.paramData[key]; } else { return this.paramData; } } return null; }; Request.prototype.header = function (name) { if (name) { return this.headers.get(name); } else { const result = {}; for (const [key, value] of this.headers) { result[key] = value; } return result; } }; Request.prototype.query = function (key) { const url = new URL(this.url); if (key) { return url.searchParams.get(key); } else { const result = {}; for (const key of url.searchParams.keys()) { result[key] = url.searchParams.get(key) || ''; } return result; } }; Request.prototype.queries = function (key) { const url = new URL(this.url); if (key) { return url.searchParams.getAll(key); } else { const result = {}; for (const key of url.searchParams.keys()) { result[key] = url.searchParams.getAll(key); } return result; } }; Request.prototype.cookie = function (key) { const cookie = this.headers.get('Cookie') || ''; const obj = (0, cookie_1.parse)(cookie); if (key) { const value = obj[key]; return value; } else { return obj; } }; Request.prototype.parseBody = function () { if (!this.parsedBody) { this.parsedBody = (0, body_1.parseBody)(this); } return this.parsedBody; };}exports.extendRequestPrototype = extendRequestPrototype;
deno

Version Info

Tagged at
2 years ago