@@ -5,67 +5,49 @@ import "github.com/valyala/fasthttp"
5
5
// Group returns a new group.
6
6
// Path auto-correction, including trailing slashes, is enabled by default.
7
7
func (g * Group ) Group (path string ) * Group {
8
- path = g .beginPath + path
9
-
10
- return g .router .Group (path )
8
+ return g .router .Group (g .prefix + path )
11
9
}
12
10
13
11
// GET is a shortcut for group.Handle(fasthttp.MethodGet, path, handler)
14
12
func (g * Group ) GET (path string , handler fasthttp.RequestHandler ) {
15
- path = g .beginPath + path
16
-
17
- g .router .GET (path , handler )
13
+ g .router .GET (g .prefix + path , handler )
18
14
}
19
15
20
16
// HEAD is a shortcut for group.Handle(fasthttp.MethodHead, path, handler)
21
17
func (g * Group ) HEAD (path string , handler fasthttp.RequestHandler ) {
22
- path = g .beginPath + path
23
-
24
- g .router .HEAD (path , handler )
18
+ g .router .HEAD (g .prefix + path , handler )
25
19
}
26
20
27
21
// OPTIONS is a shortcut for group.Handle(fasthttp.MethodOptions, path, handler)
28
22
func (g * Group ) OPTIONS (path string , handler fasthttp.RequestHandler ) {
29
- path = g .beginPath + path
30
-
31
- g .router .OPTIONS (path , handler )
23
+ g .router .OPTIONS (g .prefix + path , handler )
32
24
}
33
25
34
26
// POST is a shortcut for group.Handle(fasthttp.MethodPost, path, handler)
35
27
func (g * Group ) POST (path string , handler fasthttp.RequestHandler ) {
36
- path = g .beginPath + path
37
-
38
- g .router .POST (path , handler )
28
+ g .router .POST (g .prefix + path , handler )
39
29
}
40
30
41
31
// PUT is a shortcut for group.Handle(fasthttp.MethodPut, path, handler)
42
32
func (g * Group ) PUT (path string , handler fasthttp.RequestHandler ) {
43
- path = g .beginPath + path
44
-
45
- g .router .PUT (path , handler )
33
+ g .router .PUT (g .prefix + path , handler )
46
34
}
47
35
48
36
// PATCH is a shortcut for group.Handle(fasthttp.MethodPatch, path, handler)
49
37
func (g * Group ) PATCH (path string , handler fasthttp.RequestHandler ) {
50
- path = g .beginPath + path
51
-
52
- g .router .PATCH (path , handler )
38
+ g .router .PATCH (g .prefix + path , handler )
53
39
}
54
40
55
41
// DELETE is a shortcut for group.Handle(fasthttp.MethodDelete, path, handler)
56
42
func (g * Group ) DELETE (path string , handler fasthttp.RequestHandler ) {
57
- path = g .beginPath + path
58
-
59
- g .router .DELETE (path , handler )
43
+ g .router .DELETE (g .prefix + path , handler )
60
44
}
61
45
62
46
// ANY is a shortcut for group.Handle(router.MethodWild, path, handler)
63
47
//
64
48
// WARNING: Use only for routes where the request method is not important
65
49
func (g * Group ) ANY (path string , handler fasthttp.RequestHandler ) {
66
- path = g .beginPath + path
67
-
68
- g .router .ANY (path , handler )
50
+ g .router .ANY (g .prefix + path , handler )
69
51
}
70
52
71
53
// ServeFiles serves files from the given file system root.
@@ -77,9 +59,7 @@ func (g *Group) ANY(path string, handler fasthttp.RequestHandler) {
77
59
// Use:
78
60
// router.ServeFiles("/src/{filepath:*}", "./")
79
61
func (g * Group ) ServeFiles (path string , rootPath string ) {
80
- path = g .beginPath + path
81
-
82
- g .router .ServeFiles (path , rootPath )
62
+ g .router .ServeFiles (g .prefix + path , rootPath )
83
63
}
84
64
85
65
// ServeFilesCustom serves files from the given file system settings.
@@ -92,9 +72,7 @@ func (g *Group) ServeFiles(path string, rootPath string) {
92
72
// Use:
93
73
// router.ServeFilesCustom("/src/{filepath:*}", *customFS)
94
74
func (g * Group ) ServeFilesCustom (path string , fs * fasthttp.FS ) {
95
- path = g .beginPath + path
96
-
97
- g .router .ServeFilesCustom (path , fs )
75
+ g .router .ServeFilesCustom (g .prefix + path , fs )
98
76
}
99
77
100
78
// Handle registers a new request handler with the given path and method.
@@ -106,7 +84,5 @@ func (g *Group) ServeFilesCustom(path string, fs *fasthttp.FS) {
106
84
// frequently used, non-standardized or custom methods (e.g. for internal
107
85
// communication with a proxy).
108
86
func (g * Group ) Handle (method , path string , handler fasthttp.RequestHandler ) {
109
- path = g .beginPath + path
110
-
111
- g .router .Handle (method , path , handler )
87
+ g .router .Handle (method , g .prefix + path , handler )
112
88
}
0 commit comments