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)
| 61 | // If the template does not contain any dynamic attributes and a special handler is NOT required |
| 62 | // then it returns a nil handler. |
| 63 | func 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. |
no test coverage detected
searching dependent graphs…