Merge pull request #779 from ZaniaDeveloper/fixup-useglobal-order

Fixup #778: UseGlobal call order

Former-commit-id: 96458bcbe02df44c9ecd14440f4a292c6d9e002e
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-10-06 00:51:35 +03:00 committed by GitHub
commit 6925ed9b33

View File

@ -149,7 +149,7 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
// global begin handlers -> middleware that are registered before route registration
// -> handlers that are passed to this Handle function.
routeHandlers := joinHandlers(append(api.beginGlobalHandlers, api.middleware...), handlers)
routeHandlers := joinHandlers(api.middleware, handlers)
// -> done handlers after all
if len(api.doneGlobalHandlers) > 0 {
routeHandlers = append(routeHandlers, api.doneGlobalHandlers...) // register the done middleware, if any
@ -164,6 +164,9 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
return nil
}
// Add UseGlobal Handlers
r.use(api.beginGlobalHandlers)
// global
api.routes.register(r)