MCPcopy Create free account
hub / github.com/devfeel/dotweb / initRegisterConfigGroup

Method initRegisterConfigGroup

dotweb.go:480–513  ·  view source on GitHub ↗

init register config's route

()

Source from the content-addressed store, hash-verified

478
479// init register config's route
480func (app *DotWeb) initRegisterConfigGroup() {
481 config := app.Config
482 // support group
483 for _, v := range config.Groups {
484 if !v.IsUse {
485 continue
486 }
487 g := app.HttpServer.Group(v.Path)
488 // use middleware
489 for _, m := range v.Middlewares {
490 if !m.IsUse {
491 continue
492 }
493 if mf, isok := app.GetMiddlewareFunc(m.Name); isok {
494 g.Use(mf())
495 }
496 }
497 // init group's router
498 for _, r := range v.Routers {
499 if h, isok := app.HttpServer.Router().GetHandler(r.HandlerName); isok && r.IsUse {
500 node := g.RegisterRoute(strings.ToUpper(r.Method), r.Path, h)
501 // use middleware
502 for _, m := range r.Middlewares {
503 if !m.IsUse {
504 continue
505 }
506 if mf, isok := app.GetMiddlewareFunc(m.Name); isok {
507 node.Use(mf())
508 }
509 }
510 }
511 }
512 }
513}
514
515// initPlugins init and run plugins
516func (app *DotWeb) initPlugins() {

Callers 1

ListenAndServeMethod · 0.95

Calls 6

GetMiddlewareFuncMethod · 0.95
RouterMethod · 0.80
GroupMethod · 0.65
UseMethod · 0.65
GetHandlerMethod · 0.65
RegisterRouteMethod · 0.65

Tested by

no test coverage detected