Debian Codegraph @

pat/methods.go

raw symbols SCIP
1 package pat
2
3 /*
4 NewWithMethods returns a Pat route that matches http methods that are provided
5 */
6 func NewWithMethods(pat string, methods ...string) *Pattern {
7 p := New(pat)
8
9 methodSet := make(map[string]struct{}, len(methods))
10 for _, method := range methods {
11 methodSet[method] = struct{}{}
12 }
13 p.methods = methodSet
14
15 return p
16 }
17
18 /*
19 Delete returns a Pat route that only matches the DELETE HTTP method.
20 */
21 func Delete(pat string) *Pattern {
22 return NewWithMethods(pat, "DELETE")
23 }
24
25 /*
26 Get returns a Pat route that only matches the GET and HEAD HTTP method. HEAD
27 requests are handled transparently by net/http.
28 */
29 func Get(pat string) *Pattern {
30 return NewWithMethods(pat, "GET", "HEAD")
31 }
32
33 /*
34 Head returns a Pat route that only matches the HEAD HTTP method.
35 */
36 func Head(pat string) *Pattern {
37 return NewWithMethods(pat, "HEAD")
38 }
39
40 /*
41 Options returns a Pat route that only matches the OPTIONS HTTP method.
42 */
43 func Options(pat string) *Pattern {
44 return NewWithMethods(pat, "OPTIONS")
45 }
46
47 /*
48 Patch returns a Pat route that only matches the PATCH HTTP method.
49 */
50 func Patch(pat string) *Pattern {
51 return NewWithMethods(pat, "PATCH")
52 }
53
54 /*
55 Post returns a Pat route that only matches the POST HTTP method.
56 */
57 func Post(pat string) *Pattern {
58 return NewWithMethods(pat, "POST")
59 }
60
61 /*
62 Put returns a Pat route that only matches the PUT HTTP method.
63 */
64 func Put(pat string) *Pattern {
65 return NewWithMethods(pat, "PUT")
66 }