init register config's route
()
| 478 | |
| 479 | // init register config's route |
| 480 | func (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 |
| 516 | func (app *DotWeb) initPlugins() { |
no test coverage detected