MCPcopy Create free account
hub / github.com/kataras/iris / handlerOf

Method handlerOf

mvc/controller.go:540–578  ·  view source on GitHub ↗
(relPath, methodName string)

Source from the content-addressed store, hash-verified

538}
539
540func (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}

Callers 2

handleHTTPErrorMethod · 0.95
handleManyMethod · 0.95

Calls 12

attachInjectorMethod · 0.95
CountParamsFunction · 0.92
isBaseControllerFunction · 0.85
MethodHandlerMethod · 0.80
IsStoppedMethod · 0.80
GetRelPathMethod · 0.65
MacrosMethod · 0.65
AcquireMethod · 0.65
HandleErrorMethod · 0.65
BeginRequestMethod · 0.65
EndRequestMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected