]> 127.0.0.1 Git - front/.git/commitdiff
1 v0.1.20250321055535
authorqydysky <qydysky@foxmail.com>
Fri, 21 Mar 2025 05:53:53 +0000 (05:53 +0000)
committerGitHub <noreply@github.com>
Fri, 21 Mar 2025 05:53:53 +0000 (05:53 +0000)
http.go
ws.go

diff --git a/http.go b/http.go
index f106850b31f6ab46e2cad549538f3b0dcab1df16..29fec9ddea68fdcb7f842ba79e2c0aa2b22922f0 100644 (file)
--- a/http.go
+++ b/http.go
@@ -13,6 +13,7 @@ import (
 
        "github.com/qydysky/front/utils"
        component2 "github.com/qydysky/part/component2"
+       pctx "github.com/qydysky/part/ctx"
        pslice "github.com/qydysky/part/slice"
 )
 
@@ -104,6 +105,11 @@ func (httpDealer) Deal(ctx context.Context, reqId uint32, w http.ResponseWriter,
                chosenBack.Disable()
        }
 
+       if pctx.Done(r.Context()) {
+               logger.Warn(`W:`, fmt.Sprintf(logFormat, reqId, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, "Err", context.Canceled, time.Since(opT)))
+               return context.Canceled
+       }
+
        if resp == nil {
                logger.Warn(`W:`, fmt.Sprintf(logFormat, reqId, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, "Err", e, time.Since(opT)))
                return MarkRetry(ErrResFail)
diff --git a/ws.go b/ws.go
index ecd9071abd97054a01f5c9fe96f70537610b58ce..cf088e779ef7e0ba7ca1d322cc2a57bcf3f7f791 100644 (file)
--- a/ws.go
+++ b/ws.go
@@ -82,14 +82,15 @@ func (wsDealer) Deal(ctx context.Context, reqId uint32, w http.ResponseWriter, r
        }
        // }
 
-       if conn == nil || resp == nil {
-               return MarkRetry(ErrResFail)
-       }
-
        if pctx.Done(r.Context()) {
+               logger.Warn(`W:`, fmt.Sprintf(logFormat, reqId, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, context.Canceled, time.Since(opT)))
                return context.Canceled
        }
 
+       if conn == nil || resp == nil {
+               return MarkRetry(ErrResFail)
+       }
+
        if ok, e := chosenBack.getFiliterResHeader().Match(resp.Header); e != nil {
                logger.Warn(`W:`, fmt.Sprintf(logFormat, reqId, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, e, time.Since(opT)))
        } else if !ok {