This repository has been archived by the owner on Feb 7, 2018. It is now read-only.
/
methods.go
54 lines (45 loc) · 1.72 KB
/
methods.go
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
package route
import "github.com/volatile/core"
func methodMatch(methods []string, c *core.Context) bool {
for _, v := range methods {
if v == c.Request.Method {
return true
}
}
return false
}
// Get adds a handler to the default handlers stack.
// It executes the handler when request matches GET method and pattern.
func Get(pattern string, handler interface{}) {
Use([]string{"GET"}, pattern, handler)
}
// Post adds a handler to the default handlers stack.
// It executes the handler when request matches POST method and pattern.
func Post(pattern string, handler interface{}) {
Use([]string{"POST"}, pattern, handler)
}
// Put adds a handler to the default handlers stack.
// It executes the handler when request matches PUT method and pattern.
func Put(pattern string, handler interface{}) {
Use([]string{"PUT"}, pattern, handler)
}
// Patch adds a handler to the default handlers stack.
// It executes the handler when request matches PATCH method and pattern.
func Patch(pattern string, handler interface{}) {
Use([]string{"PATCH"}, pattern, handler)
}
// Delete adds a handler to the default handlers stack.
// It executes the handler when request matches DELETE method and pattern.
func Delete(pattern string, handler interface{}) {
Use([]string{"DELETE"}, pattern, handler)
}
// Head adds a handler to the default handlers stack.
// It executes the handler when request matches HEAD method and pattern.
func Head(pattern string, handler interface{}) {
Use([]string{"HEAD"}, pattern, handler)
}
// Options adds a handler to the default handlers stack.
// It executes the handler when request matches OPTIONS method and pattern.
func Options(pattern string, handler interface{}) {
Use([]string{"OPTIONS"}, pattern, handler)
}