Group is used for Routes with common prefix to define a new sub-router with optional middleware. api := app.Group("/api") api.Get("/users", handler)
(prefix string, handlers ...any)
| 191 | // api := app.Group("/api") |
| 192 | // api.Get("/users", handler) |
| 193 | func (grp *Group) Group(prefix string, handlers ...any) Router { |
| 194 | prefix = getGroupPath(grp.Prefix, prefix) |
| 195 | if len(handlers) > 0 { |
| 196 | converted := collectHandlers("group", handlers...) |
| 197 | grp.app.register([]string{methodUse}, prefix, grp, converted...) |
| 198 | } |
| 199 | |
| 200 | // Create new group |
| 201 | newGrp := &Group{Prefix: prefix, app: grp.app, parentGroup: grp} |
| 202 | if err := grp.app.hooks.executeOnGroupHooks(*newGrp); err != nil { |
| 203 | panic(err) |
| 204 | } |
| 205 | |
| 206 | return newGrp |
| 207 | } |
| 208 | |
| 209 | // Domain creates a new router scoped to the given hostname pattern within |
| 210 | // this group. Routes registered through the returned Router inherit the |
no test coverage detected