-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathin_group.go
More file actions
52 lines (43 loc) · 913 Bytes
/
pathin_group.go
File metadata and controls
52 lines (43 loc) · 913 Bytes
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
package pathin
type DestGroup interface {
destTarget
Root() *Root
AddDestGroup(string, ...HandlerFunc) DestGroup
AddDest(string, ...HandlerFunc)
}
type Group struct {
root *Root
name string
parentGroup DestGroup
handlers []HandlerFunc
}
func (g Group) Name() string {
return g.name
}
func (g Group) ParentGroup() DestGroup {
return g.parentGroup
}
func (g Group) Handlers() []HandlerFunc {
return g.handlers
}
func (g *Group) AddDestGroup(name string, handlersChain ...HandlerFunc) DestGroup {
return &Group{
name: name,
root: g.root,
parentGroup: g,
handlers: handlersChain,
}
}
func (g Group) Root() *Root {
return g.root
}
func (g *Group) AddDest(name string, handlersChain ...HandlerFunc) {
if g.root == nil {
panic("Whoops")
}
g.root.typeHandlers[name] = &target{
name: name,
parentGroup: g,
handlers: handlersChain,
}
}