File tree Expand file tree Collapse file tree 2 files changed +63
-13
lines changed Expand file tree Collapse file tree 2 files changed +63
-13
lines changed Original file line number Diff line number Diff line change @@ -175,18 +175,6 @@ func New() (e *Echo) {
175175 return
176176}
177177
178- // Group creates a new sub router with prefix. It inherits all properties from
179- // the parent. Passing middleware overrides parent middleware.
180- func (e * Echo ) Group (pfx string , m ... Middleware ) * Echo {
181- g := * e
182- g .prefix = g .prefix + pfx
183- if len (m ) > 0 {
184- g .middleware = nil
185- g .Use (m ... )
186- }
187- return & g
188- }
189-
190178// Router returns router.
191179func (e * Echo ) Router () * Router {
192180 return e .router
@@ -355,6 +343,18 @@ func (e *Echo) URL(h Handler, params ...interface{}) string {
355343 return e .URI (h , params ... )
356344}
357345
346+ // Group creates a new sub router with prefix. It inherits all properties from
347+ // the parent. Passing middleware overrides parent middleware.
348+ func (e * Echo ) Group (prefix string , m ... Middleware ) * Group {
349+ g := & Group {* e }
350+ g .echo .prefix += prefix
351+ if len (m ) > 0 {
352+ g .echo .middleware = nil
353+ g .Use (m ... )
354+ }
355+ return g
356+ }
357+
358358func (e * Echo ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
359359 c := e .pool .Get ().(* Context )
360360 h , echo := e .router .Find (r .Method , r .URL .Path , c )
Original file line number Diff line number Diff line change @@ -2,6 +2,56 @@ package echo
22
33type (
44 Group struct {
5- * Echo
5+ echo Echo
66 }
77)
8+
9+ func (g * Group ) Use (m ... Middleware ) {
10+ for _ , h := range m {
11+ g .echo .middleware = append (g .echo .middleware , wrapMiddleware (h ))
12+ }
13+ }
14+
15+ func (g * Group ) Connect (path string , h Handler ) {
16+ g .echo .Connect (path , h )
17+ }
18+
19+ func (g * Group ) Delete (path string , h Handler ) {
20+ g .echo .Delete (path , h )
21+ }
22+
23+ func (g * Group ) Get (path string , h Handler ) {
24+ g .echo .Get (path , h )
25+ }
26+
27+ func (g * Group ) Head (path string , h Handler ) {
28+ g .echo .Head (path , h )
29+ }
30+
31+ func (g * Group ) Options (path string , h Handler ) {
32+ g .echo .Options (path , h )
33+ }
34+
35+ func (g * Group ) Patch (path string , h Handler ) {
36+ g .echo .Patch (path , h )
37+ }
38+
39+ func (g * Group ) Post (path string , h Handler ) {
40+ g .echo .Post (path , h )
41+ }
42+
43+ func (g * Group ) Put (path string , h Handler ) {
44+ g .echo .Put (path , h )
45+ }
46+
47+ func (g * Group ) Trace (path string , h Handler ) {
48+ g .echo .Trace (path , h )
49+ }
50+
51+ func (g * Group ) WebSocket (path string , h HandlerFunc ) {
52+ g .echo .WebSocket (path , h )
53+ }
54+
55+ func (g * Group ) Group (prefix string , m ... Middleware ) * Group {
56+ return g .echo .Group (prefix , m ... )
57+ }
You can’t perform that action at this time.
0 commit comments