-
Notifications
You must be signed in to change notification settings - Fork 37
/
group.go
90 lines (74 loc) · 2.83 KB
/
group.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package air
// Group is a set of sub-routes for a specified route. It can be used for inner
// routes that share common gases or functionality that should be separate from
// the parent while still inheriting from it.
type Group struct {
// Air is where the group belongs.
Air *Air
// Prefix is the prefix of all route paths.
//
// All paths of routes registered by the group will share the `Prefix`.
//
// The `Prefix` may consit of STATIC and PARAM components, but it must
// not contain ANY component.
Prefix string
// Gases is the group-level gases.
//
// All gases of routes registered by the group will share the `Gases`
// at the bottom of the stack.
//
// The `Gases` is always FILO.
Gases []Gas
}
// GET is just like the `Air.GET`.
func (g *Group) GET(path string, h Handler, gases ...Gas) {
g.Air.GET(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// HEAD is just like the `Air.HEAD`.
func (g *Group) HEAD(path string, h Handler, gases ...Gas) {
g.Air.HEAD(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// POST is just like the `Air.POST`.
func (g *Group) POST(path string, h Handler, gases ...Gas) {
g.Air.POST(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// PUT is just like the `Air.PUT`.
func (g *Group) PUT(path string, h Handler, gases ...Gas) {
g.Air.PUT(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// PATCH is just like the `Air.PATCH`.
func (g *Group) PATCH(path string, h Handler, gases ...Gas) {
g.Air.PATCH(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// DELETE is just like the `Air.DELETE`.
func (g *Group) DELETE(path string, h Handler, gases ...Gas) {
g.Air.DELETE(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// CONNECT is just like the `Air.CONNECT`.
func (g *Group) CONNECT(path string, h Handler, gases ...Gas) {
g.Air.CONNECT(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// OPTIONS is just like the `Air.OPTIONS`.
func (g *Group) OPTIONS(path string, h Handler, gases ...Gas) {
g.Air.OPTIONS(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// TRACE is just like the `Air.TRACE`.
func (g *Group) TRACE(path string, h Handler, gases ...Gas) {
g.Air.TRACE(g.Prefix+path, h, append(g.Gases, gases...)...)
}
// BATCH is just like the `Air.BATCH`.
func (g *Group) BATCH(methods []string, path string, h Handler, gases ...Gas) {
g.Air.BATCH(methods, g.Prefix+path, h, append(g.Gases, gases...)...)
}
// FILE is just like the `Air.FILE`.
func (g *Group) FILE(path, file string, gases ...Gas) {
g.Air.FILE(g.Prefix+path, file, append(g.Gases, gases...)...)
}
// FILES is just like the `Air.FILES`.
func (g *Group) FILES(prefix, root string, gases ...Gas) {
g.Air.FILES(g.Prefix+prefix, root, append(g.Gases, gases...)...)
}
// Group is just like the `Air.Group`.
func (g *Group) Group(prefix string, gases ...Gas) *Group {
return g.Air.Group(g.Prefix+prefix, append(g.Gases, gases...)...)
}