]> 127.0.0.1 Git - part/.git/commitdiff
1
authorqydysky <qydysky@foxmail.com>
Sat, 9 Dec 2023 06:42:05 +0000 (14:42 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 9 Dec 2023 06:42:05 +0000 (14:42 +0800)
web/Web.go

index e7716a8fde59709aede25c002380411c1b0cda94..59cb80afa1693f69d9620818d5231fc2636a1cf7 100644 (file)
@@ -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 {