(relPath, methodName string)
| 538 | } |
| 539 | |
| 540 | func (c *ControllerActivator) handlerOf(relPath, methodName string) context.Handler { |
| 541 | c.attachInjector() |
| 542 | |
| 543 | fullpath := c.app.Router.GetRelPath() + relPath |
| 544 | paramsCount := macro.CountParams(fullpath, *c.app.Router.Macros()) |
| 545 | handler := c.injector.MethodHandler(methodName, paramsCount) |
| 546 | |
| 547 | if isBaseController(c.Type) { |
| 548 | return func(ctx *context.Context) { |
| 549 | ctrl, err := c.injector.Acquire(ctx) |
| 550 | if err != nil { |
| 551 | // if err != hero.ErrStopExecution { |
| 552 | // c.injector.Container.GetErrorHandler(ctx).HandleError(ctx, err) |
| 553 | // } |
| 554 | c.injector.Container.GetErrorHandler(ctx).HandleError(ctx, err) |
| 555 | // allow skipping struct field bindings |
| 556 | // errors by a custom error handler. |
| 557 | if ctx.IsStopped() { |
| 558 | return |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | b := ctrl.Interface().(BaseController) |
| 563 | // init the request. |
| 564 | b.BeginRequest(ctx) |
| 565 | |
| 566 | // if begin request stopped the execution. |
| 567 | if ctx.IsStopped() { |
| 568 | return |
| 569 | } |
| 570 | |
| 571 | handler(ctx) |
| 572 | |
| 573 | b.EndRequest(ctx) |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | return handler |
| 578 | } |
no test coverage detected