| 1 |
package pat |
| 2 |
|
| 3 |
|
| 4 |
|
| 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 |
|
| 20 |
|
| 21 |
func Delete(pat string) *Pattern { |
| 22 |
return NewWithMethods(pat, "DELETE") |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
func Get(pat string) *Pattern { |
| 30 |
return NewWithMethods(pat, "GET", "HEAD") |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
func Head(pat string) *Pattern { |
| 37 |
return NewWithMethods(pat, "HEAD") |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
func Options(pat string) *Pattern { |
| 44 |
return NewWithMethods(pat, "OPTIONS") |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
func Patch(pat string) *Pattern { |
| 51 |
return NewWithMethods(pat, "PATCH") |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
func Post(pat string) *Pattern { |
| 58 |
return NewWithMethods(pat, "POST") |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
func Put(pat string) *Pattern { |
| 65 |
return NewWithMethods(pat, "PUT") |
| 66 |
} |