Skip to content

Commit a9f3558

Browse files
halvardssmiuioiua
andauthored
feat(http/unstable): methods module (denoland#4320)
* Added methods to http namespace * Renamed type and const Co-authored-by: Asher Gomez <[email protected]> * Cleaned up methods and added support for jsr * Fixed linting * unstable notices --------- Co-authored-by: Asher Gomez <[email protected]>
1 parent 7a8b51f commit a9f3558

File tree

4 files changed

+324
-0
lines changed

4 files changed

+324
-0
lines changed

http/deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"./cookie": "./cookie.ts",
77
"./etag": "./etag.ts",
88
"./file-server": "./file_server.ts",
9+
"./method": "./method.ts",
910
"./negotiation": "./negotiation.ts",
1011
"./server-sent-event-stream": "./server_sent_event_stream.ts",
1112
"./status": "./status.ts",

http/method.ts

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2+
// This module is browser compatible.
3+
// This module is generated from {@link https://www.iana.org/assignments/http-methods/http-methods.xhtml#methods | IANA Hypertext Transfer Protocol (HTTP) Method Registry}
4+
5+
/**
6+
* HTTP Methods derived from IANA Hypertext Transfer Protocol (HTTP) Method Registry
7+
*
8+
* > [!WARNING]
9+
* > **UNSTABLE**: New API, yet to be vetted.
10+
*
11+
* @experimental
12+
*
13+
* @see {@link https://www.iana.org/assignments/http-methods/http-methods.xhtml#methods | IANA Hypertext Transfer Protocol (HTTP) Method Registry}
14+
*/
15+
export const METHOD = {
16+
/**
17+
* ACL (Safe: no; Idempotent: yes)
18+
*
19+
* @see {@link https://www.iana.org/go/rfc3744 | RFC3744, Section 8.1}
20+
*/
21+
Acl: "ACL",
22+
23+
/**
24+
* BASELINE-CONTROL (Safe: no; Idempotent: yes)
25+
*
26+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 12.6}
27+
*/
28+
BaselineControl: "BASELINE-CONTROL",
29+
30+
/**
31+
* BIND (Safe: no; Idempotent: yes)
32+
*
33+
* @see {@link https://www.iana.org/go/rfc5842 | RFC5842, Section 4}
34+
*/
35+
Bind: "BIND",
36+
37+
/**
38+
* CHECKIN (Safe: no; Idempotent: yes)
39+
*
40+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 4.4, Section 9.4}
41+
*/
42+
Checkin: "CHECKIN",
43+
44+
/**
45+
* CHECKOUT (Safe: no; Idempotent: yes)
46+
*
47+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 4.3, Section 8.8}
48+
*/
49+
Checkout: "CHECKOUT",
50+
51+
/**
52+
* CONNECT (Safe: no; Idempotent: no)
53+
*
54+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.6}
55+
*/
56+
Connect: "CONNECT",
57+
58+
/**
59+
* COPY (Safe: no; Idempotent: yes)
60+
*
61+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.8}
62+
*/
63+
Copy: "COPY",
64+
65+
/**
66+
* DELETE (Safe: no; Idempotent: yes)
67+
*
68+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.5}
69+
*/
70+
Delete: "DELETE",
71+
72+
/**
73+
* GET (Safe: yes; Idempotent: yes)
74+
*
75+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.1}
76+
*/
77+
Get: "GET",
78+
79+
/**
80+
* HEAD (Safe: yes; Idempotent: yes)
81+
*
82+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.2}
83+
*/
84+
Head: "HEAD",
85+
86+
/**
87+
* LABEL (Safe: no; Idempotent: yes)
88+
*
89+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 8.2}
90+
*/
91+
Label: "LABEL",
92+
93+
/**
94+
* LINK (Safe: no; Idempotent: yes)
95+
*
96+
* @see {@link https://www.iana.org/go/rfc2068 | RFC2068, Section 19.6.1.2}
97+
*/
98+
Link: "LINK",
99+
100+
/**
101+
* LOCK (Safe: no; Idempotent: no)
102+
*
103+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.10}
104+
*/
105+
Lock: "LOCK",
106+
107+
/**
108+
* MERGE (Safe: no; Idempotent: yes)
109+
*
110+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 11.2}
111+
*/
112+
Merge: "MERGE",
113+
114+
/**
115+
* MKACTIVITY (Safe: no; Idempotent: yes)
116+
*
117+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 13.5}
118+
*/
119+
Mkactivity: "MKACTIVITY",
120+
121+
/**
122+
* MKCALENDAR (Safe: no; Idempotent: yes)
123+
*
124+
* @see {@link https://www.iana.org/go/rfc4791 | RFC4791, Section 5.3.1}
125+
* @see {@link https://www.iana.org/go/rfc8144 | RFC8144, Section 2.3}
126+
*/
127+
Mkcalendar: "MKCALENDAR",
128+
129+
/**
130+
* MKCOL (Safe: no; Idempotent: yes)
131+
*
132+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.3}
133+
* @see {@link https://www.iana.org/go/rfc5689 | RFC5689, Section 3}
134+
* @see {@link https://www.iana.org/go/rfc8144 | RFC8144, Section 2.3}
135+
*/
136+
Mkcol: "MKCOL",
137+
138+
/**
139+
* MKREDIRECTREF (Safe: no; Idempotent: yes)
140+
*
141+
* @see {@link https://www.iana.org/go/rfc4437 | RFC4437, Section 6}
142+
*/
143+
Mkredirectref: "MKREDIRECTREF",
144+
145+
/**
146+
* MKWORKSPACE (Safe: no; Idempotent: yes)
147+
*
148+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 6.3}
149+
*/
150+
Mkworkspace: "MKWORKSPACE",
151+
152+
/**
153+
* MOVE (Safe: no; Idempotent: yes)
154+
*
155+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.9}
156+
*/
157+
Move: "MOVE",
158+
159+
/**
160+
* OPTIONS (Safe: yes; Idempotent: yes)
161+
*
162+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.7}
163+
*/
164+
Options: "OPTIONS",
165+
166+
/**
167+
* ORDERPATCH (Safe: no; Idempotent: yes)
168+
*
169+
* @see {@link https://www.iana.org/go/rfc3648 | RFC3648, Section 7}
170+
*/
171+
Orderpatch: "ORDERPATCH",
172+
173+
/**
174+
* PATCH (Safe: no; Idempotent: no)
175+
*
176+
* @see {@link https://www.iana.org/go/rfc5789 | RFC5789, Section 2}
177+
*/
178+
Patch: "PATCH",
179+
180+
/**
181+
* POST (Safe: no; Idempotent: no)
182+
*
183+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.3}
184+
*/
185+
Post: "POST",
186+
187+
/**
188+
* PRI (Safe: yes; Idempotent: yes)
189+
*
190+
* @see {@link https://www.iana.org/go/rfc9113 | RFC9113, Section 3.4}
191+
*/
192+
Pri: "PRI",
193+
194+
/**
195+
* PROPFIND (Safe: yes; Idempotent: yes)
196+
*
197+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.1}
198+
* @see {@link https://www.iana.org/go/rfc8144 | RFC8144, Section 2.1}
199+
*/
200+
Propfind: "PROPFIND",
201+
202+
/**
203+
* PROPPATCH (Safe: no; Idempotent: yes)
204+
*
205+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.2}
206+
* @see {@link https://www.iana.org/go/rfc8144 | RFC8144, Section 2.2}
207+
*/
208+
Proppatch: "PROPPATCH",
209+
210+
/**
211+
* PUT (Safe: no; Idempotent: yes)
212+
*
213+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.4}
214+
*/
215+
Put: "PUT",
216+
217+
/**
218+
* REBIND (Safe: no; Idempotent: yes)
219+
*
220+
* @see {@link https://www.iana.org/go/rfc5842 | RFC5842, Section 6}
221+
*/
222+
Rebind: "REBIND",
223+
224+
/**
225+
* REPORT (Safe: yes; Idempotent: yes)
226+
*
227+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 3.6}
228+
* @see {@link https://www.iana.org/go/rfc8144 | RFC8144, Section 2.1}
229+
*/
230+
Report: "REPORT",
231+
232+
/**
233+
* SEARCH (Safe: yes; Idempotent: yes)
234+
*
235+
* @see {@link https://www.iana.org/go/rfc5323 | RFC5323, Section 2}
236+
*/
237+
Search: "SEARCH",
238+
239+
/**
240+
* TRACE (Safe: yes; Idempotent: yes)
241+
*
242+
* @see {@link https://www.iana.org/go/rfc9110 | RFC9110, Section 9.3.8}
243+
*/
244+
Trace: "TRACE",
245+
246+
/**
247+
* UNBIND (Safe: no; Idempotent: yes)
248+
*
249+
* @see {@link https://www.iana.org/go/rfc5842 | RFC5842, Section 5}
250+
*/
251+
Unbind: "UNBIND",
252+
253+
/**
254+
* UNCHECKOUT (Safe: no; Idempotent: yes)
255+
*
256+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 4.5}
257+
*/
258+
Uncheckout: "UNCHECKOUT",
259+
260+
/**
261+
* UNLINK (Safe: no; Idempotent: yes)
262+
*
263+
* @see {@link https://www.iana.org/go/rfc2068 | RFC2068, Section 19.6.1.3}
264+
*/
265+
Unlink: "UNLINK",
266+
267+
/**
268+
* UNLOCK (Safe: no; Idempotent: yes)
269+
*
270+
* @see {@link https://www.iana.org/go/rfc4918 | RFC4918, Section 9.11}
271+
*/
272+
Unlock: "UNLOCK",
273+
274+
/**
275+
* UPDATE (Safe: no; Idempotent: yes)
276+
*
277+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 7.1}
278+
*/
279+
Update: "UPDATE",
280+
281+
/**
282+
* UPDATEREDIRECTREF (Safe: no; Idempotent: yes)
283+
*
284+
* @see {@link https://www.iana.org/go/rfc4437 | RFC4437, Section 7}
285+
*/
286+
Updateredirectref: "UPDATEREDIRECTREF",
287+
288+
/**
289+
* VERSION-CONTROL (Safe: no; Idempotent: yes)
290+
*
291+
* @see {@link https://www.iana.org/go/rfc3253 | RFC3253, Section 3.5}
292+
*/
293+
VersionControl: "VERSION-CONTROL",
294+
} as const;
295+
296+
/**
297+
* A HTTP Method
298+
*
299+
* > [!WARNING]
300+
* > **UNSTABLE**: New API, yet to be vetted.
301+
*
302+
* @experimental
303+
*/
304+
export type Method = typeof METHOD[keyof typeof METHOD];

http/method_test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2+
3+
import { METHOD } from "./method.ts";
4+
import { assertEquals } from "@std/assert";
5+
6+
Deno.test({
7+
name: "METHOD",
8+
fn() {
9+
// just spot check a few common methods
10+
assertEquals(METHOD.Head, "HEAD");
11+
assertEquals(METHOD.Get, "GET");
12+
assertEquals(METHOD.Post, "POST");
13+
assertEquals(METHOD.Put, "PUT");
14+
assertEquals(METHOD.Delete, "DELETE");
15+
assertEquals(METHOD.Options, "OPTIONS");
16+
assertEquals(METHOD.Label, "LABEL");
17+
},
18+
});

http/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ export * from "./signed_cookie.ts";
6969
export * from "./server_sent_event_stream.ts";
7070
export * from "./user_agent.ts";
7171
export * from "./file_server.ts";
72+
export * from "./method.ts";

0 commit comments

Comments
 (0)