-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.go
65 lines (52 loc) · 1.15 KB
/
route.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
55
56
57
58
59
60
61
62
63
64
65
package fipple
type Encoding int
const (
None Encoding = iota
Gzip
Deflate
)
type HttpMethod string
const (
NotSupported HttpMethod = "" //not http
GET HttpMethod = "GET"
PUT HttpMethod = "PUT"
POST HttpMethod = "POST"
DELETE HttpMethod = "DELETE"
HEAD = "HEAD"
)
type action func(*Context)
type route struct {
path string
// encoding Encoding
httpMethod HttpMethod
action action
paras []string //named parameters
}
func (r *route) addPara(para string) {
if r.paras == nil {
r.paras = make([]string, 1)
r.paras[0] = para
} else {
r.paras = append(r.paras, para)
}
}
/*
func Rpc(name string, execFunc func()) *route {
return &route{name,Gob,None,execFunc}
}*/
func GetRoute(path string, action action) *route {
return &route{path, GET, action, nil}
}
func PostRoute(path string, action action) *route {
return &route{path, POST, action, nil}
}
func PutRoute(path string, action action) *route {
return &route{path, PUT, action, nil}
}
func DeleteRoute(path string, action action) *route {
return &route{path, DELETE, action, nil}
}
/*
type RpcRoute struct {
name string
}*/