MCPcopy
hub / github.com/gofiber/fiber / Group

Method Group

group.go:193–207  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

191// api := app.Group("/api")
192// api.Get("/users", handler)
193func (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

Callers 1

RouteMethod · 0.95

Calls 4

getGroupPathFunction · 0.85
collectHandlersFunction · 0.85
registerMethod · 0.80
executeOnGroupHooksMethod · 0.80

Tested by

no test coverage detected