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

Function MakeHandler

macro/handler/handler.go:63–81  ·  view source on GitHub ↗

MakeHandler creates and returns a handler from a macro template, the handler evaluates each of the parameters if necessary at all. If the template does not contain any dynamic attributes and a special handler is NOT required then it returns a nil handler.

(tmpl macro.Template)

Source from the content-addressed store, hash-verified

61// If the template does not contain any dynamic attributes and a special handler is NOT required
62// then it returns a nil handler.
63func MakeHandler(tmpl macro.Template) context.Handler {
64 filter := MakeFilter(tmpl)
65
66 return func(ctx *context.Context) {
67 if !filter(ctx) {
68 if ctx.GetCurrentRoute().StatusErrorCode() == ctx.GetStatusCode() {
69 ctx.Next()
70 } else {
71 ctx.StopExecution()
72 }
73
74 return
75 }
76
77 // if all passed or the next is the registered error handler to handle this status code,
78 // just continue.
79 ctx.Next()
80 }
81}
82
83// MakeFilter returns a Filter which reports whether a specific macro template
84// and its parameters pass the serve-time validation.

Callers 1

NewRouteFunction · 0.92

Calls 6

MakeFilterFunction · 0.85
GetCurrentRouteMethod · 0.80
GetStatusCodeMethod · 0.80
NextMethod · 0.80
StopExecutionMethod · 0.80
StatusErrorCodeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…