1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

Add a better example for the recaptcha middleware as requested at: https://github.com/kataras/iris/issues/799

Former-commit-id: 85c3286a9d6be5cf47631e7608f70f3790934e64
This commit is contained in:
kataras
2017-11-04 02:59:21 +02:00
parent 7cd78df9e3
commit ef41e07d4e
11 changed files with 153 additions and 59 deletions

View File

@@ -146,6 +146,13 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
}
fullpath := api.relativePath + relativePath // for now, keep the last "/" if any, "/xyz/"
if len(handlers) == 0 {
api.reporter.Add("missing handlers for route %s: %s", method, fullpath)
return nil
}
// before join the middleware + handlers + done handlers.
possibleMainHandlerName := context.HandlerName(handlers[0])
// global begin handlers -> middleware that are registered before route registration
// -> handlers that are passed to this Handle function.
@@ -158,7 +165,7 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
// here we separate the subdomain and relative path
subdomain, path := splitSubdomainAndPath(fullpath)
r, err := NewRoute(method, subdomain, path, routeHandlers, api.macros)
r, err := NewRoute(method, subdomain, path, possibleMainHandlerName, routeHandlers, api.macros)
if err != nil { // template path parser errors:
api.reporter.Add("%v -> %s:%s:%s", err, method, subdomain, path)
return nil