-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrouter.go
64 lines (56 loc) · 1.15 KB
/
router.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
package bast
//Pattern Pattern obj
type Pattern struct {
Method string
Pattern string
Fn func(ctx *Context)
Parameter interface{}
Name string
Service string
authorization bool
publish bool
publishFinish bool
toRouter bool
}
//Auth need api authorization
//eq Authorization
func (c *Pattern) Auth() *Pattern {
c.authorization = true
return c
}
//Unauth need api Unauthorization
//eq Unauthorization
func (c *Pattern) Unauth() *Pattern {
c.authorization = false
return c
}
//Registry register to etcd etc.
func (c *Pattern) Registry(service string) *Pattern {
c.publish = true
c.Service = service
return c
}
//Unregistry unregister to etcd etc.
func (c *Pattern) Unregistry() *Pattern {
c.publish = false
c.Service = ""
return c
}
//Param set pouter parameter
func (c *Pattern) Param(Parameter interface{}) *Pattern {
c.Parameter = Parameter
return c
}
//Nickname set nickname
func (c *Pattern) Nickname(name string) *Pattern {
c.Name = name
return c
}
//Router register to httpRouter
func (c *Pattern) Router() *Pattern {
if !c.toRouter {
doHandle(c)
c.toRouter = true
}
return c
}