Skip to content

Commit f14b465

Browse files
committed
Add handler
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 75c01ee commit f14b465

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/web/route.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
3131
func(ctx *context.Context) goctx.CancelFunc,
3232
func(*context.APIContext),
3333
func(*context.PrivateContext),
34+
func(*context.PrivateContext) goctx.CancelFunc,
3435
func(http.Handler) http.Handler:
3536
default:
3637
panic(fmt.Sprintf("Unsupported handler type: %#v", t))
@@ -59,6 +60,15 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
5960
if ctx.Written() {
6061
return
6162
}
63+
case func(*context.PrivateContext) goctx.CancelFunc:
64+
ctx := context.GetPrivateContext(req)
65+
cancel := t(ctx)
66+
if cancel != nil {
67+
defer cancel()
68+
}
69+
if ctx.Written() {
70+
return
71+
}
6272
case func(ctx *context.Context):
6373
ctx := context.GetContext(req)
6474
t(ctx)

0 commit comments

Comments
 (0)