...
1 package pat
2
3
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
21 func Delete(pat string) *Pattern {
22 return NewWithMethods(pat, "DELETE")
23 }
24
25
29 func Get(pat string) *Pattern {
30 return NewWithMethods(pat, "GET", "HEAD")
31 }
32
33
36 func Head(pat string) *Pattern {
37 return NewWithMethods(pat, "HEAD")
38 }
39
40
43 func Options(pat string) *Pattern {
44 return NewWithMethods(pat, "OPTIONS")
45 }
46
47
50 func Patch(pat string) *Pattern {
51 return NewWithMethods(pat, "PATCH")
52 }
53
54
57 func Post(pat string) *Pattern {
58 return NewWithMethods(pat, "POST")
59 }
60
61
64 func Put(pat string) *Pattern {
65 return NewWithMethods(pat, "PUT")
66 }
67
View as plain text