(ctx Context)
| 60 | } |
| 61 | |
| 62 | func (bm *BaseMiddleware) Next(ctx Context) error { |
| 63 | if ctx.getMiddlewareStep() == "" { |
| 64 | ctx.setMiddlewareStep(middleware_App) |
| 65 | } |
| 66 | if bm.next == nil { |
| 67 | if ctx.getMiddlewareStep() == middleware_App { |
| 68 | ctx.setMiddlewareStep(middleware_Group) |
| 69 | if len(ctx.RouterNode().GroupMiddlewares()) > 0 { |
| 70 | return ctx.RouterNode().GroupMiddlewares()[0].Handle(ctx) |
| 71 | } |
| 72 | } |
| 73 | if ctx.getMiddlewareStep() == middleware_Group { |
| 74 | ctx.setMiddlewareStep(middleware_Router) |
| 75 | if len(ctx.RouterNode().Middlewares()) > 0 { |
| 76 | return ctx.RouterNode().Middlewares()[0].Handle(ctx) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if ctx.getMiddlewareStep() == middleware_Router { |
| 81 | return ctx.Handler()(ctx) |
| 82 | } |
| 83 | } else { |
| 84 | // check exclude config |
| 85 | if ctx.RouterNode().Node().hasExcludeMiddleware && bm.next.HasExclude() { |
| 86 | if bm.next.ExistsExcludeRouter(ctx.RouterNode().Node().fullPath) { |
| 87 | return bm.next.Next(ctx) |
| 88 | } |
| 89 | } |
| 90 | return bm.next.Handle(ctx) |
| 91 | } |
| 92 | return nil |
| 93 | } |
| 94 | |
| 95 | // Exclude Exclude this middleware with router |
| 96 | func (bm *BaseMiddleware) Exclude(routers ...string) { |
nothing calls this directly
no test coverage detected