diff --git a/modules/web/route.go b/modules/web/route.go index 3c6513da626ce..9b08510264bfe 100644 --- a/modules/web/route.go +++ b/modules/web/route.go @@ -31,6 +31,7 @@ func Wrap(handlers ...interface{}) http.HandlerFunc { func(ctx *context.Context) goctx.CancelFunc, func(*context.APIContext), func(*context.PrivateContext), + func(*context.PrivateContext) goctx.CancelFunc, func(http.Handler) http.Handler: default: panic(fmt.Sprintf("Unsupported handler type: %#v", t)) @@ -59,6 +60,15 @@ func Wrap(handlers ...interface{}) http.HandlerFunc { if ctx.Written() { return } + case func(*context.PrivateContext) goctx.CancelFunc: + ctx := context.GetPrivateContext(req) + cancel := t(ctx) + if cancel != nil { + defer cancel() + } + if ctx.Written() { + return + } case func(ctx *context.Context): ctx := context.GetContext(req) t(ctx)