From 0d339ce91e1fb679d4ed02308d63fc8a1317a105 Mon Sep 17 00:00:00 2001 From: ZaniaDeveloper Date: Thu, 5 Oct 2017 08:15:05 +0300 Subject: [PATCH] Fixup #778 UseGlobal call order. Former-commit-id: 293b37e6071e55aaa6c39bf12db9aed5c453c235 --- core/router/api_builder.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/router/api_builder.go b/core/router/api_builder.go index b287bb10..faff3cc5 100644 --- a/core/router/api_builder.go +++ b/core/router/api_builder.go @@ -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)