From 97d8d12d7531e73277dcc339fa668d89df6b6e3b Mon Sep 17 00:00:00 2001 From: qydysky Date: Sat, 9 Dec 2023 14:42:05 +0800 Subject: [PATCH] 1 --- web/Web.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/Web.go b/web/Web.go index e7716a8..59cb80a 100644 --- a/web/Web.go +++ b/web/Web.go @@ -43,8 +43,9 @@ func (t *Web) Handle(path_func map[string]func(http.ResponseWriter, *http.Reques } } -func (t *Web) Shutdown() { - t.Server.Shutdown(context.Background()) +func (t *Web) Shutdown(ctx ...context.Context) { + ctx = append(ctx, context.Background()) + t.Server.Shutdown(ctx[0]) } type WebSync struct { @@ -84,15 +85,16 @@ func NewSyncMap(conf *http.Server, m *WebPath, matchFunc ...func(path string) (f if ok { f(w, r) } else { - w.WriteHeader(http.StatusNotFound) + WithStatusCode(w, http.StatusNotFound) } }) return } -func (t *WebSync) Shutdown() { - t.Server.Shutdown(context.Background()) +func (t *WebSync) Shutdown(ctx ...context.Context) { + ctx = append(ctx, context.Background()) + t.Server.Shutdown(ctx[0]) } type WebPath struct { -- 2.39.2