Group creates a new sub-router with a common prefix, scoped to the domain pattern. Routes registered through the returned Router also inherit the domain filter.
(prefix string, handlers ...any)
| 558 | // Group creates a new sub-router with a common prefix, scoped to the domain pattern. |
| 559 | // Routes registered through the returned Router also inherit the domain filter. |
| 560 | func (d *domainRouter) Group(prefix string, handlers ...any) Router { |
| 561 | fullPrefix := d.registerPath(prefix) |
| 562 | |
| 563 | if len(handlers) > 0 { |
| 564 | converted := collectHandlers("domain", handlers...) |
| 565 | wrapped := d.wrapHandlers(converted) |
| 566 | d.app.register([]string{methodUse}, fullPrefix, d.registerGroup(), wrapped...) |
| 567 | } |
| 568 | |
| 569 | // Create a new group on the app |
| 570 | newGrp := &Group{Prefix: fullPrefix, app: d.app, parentGroup: d.group} |
| 571 | if err := d.app.hooks.executeOnGroupHooks(*newGrp); err != nil { |
| 572 | panic(err) |
| 573 | } |
| 574 | |
| 575 | return &domainRouter{ |
| 576 | app: d.app, |
| 577 | group: newGrp, |
| 578 | matcher: d.matcher, |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | // RouteChain creates a Registering instance for the domain router. |
| 583 | func (d *domainRouter) RouteChain(path string) Register { |
no test coverage detected