]> 127.0.0.1 Git - front/.git/commitdiff
1 v0.1.20241008064526
authorqydysky <qydysky@foxmail.com>
Tue, 8 Oct 2024 06:43:33 +0000 (06:43 +0000)
committerGitHub <noreply@github.com>
Tue, 8 Oct 2024 06:43:33 +0000 (06:43 +0000)
config.go
http.go

index 6d8beaca953ac26ed29626890c8ea7cb4d343cb6..064059861fec3bb4fffdf7ccbfa952ee4b453c56 100755 (executable)
--- a/config.go
+++ b/config.go
@@ -181,7 +181,7 @@ func (t *Config) SwapSign(ctx context.Context, logger Logger) {
                                                e = component2.Get[reqDealer]("http").Deal(r.Context(), w, r, routePath, backIs[i], logger, t.BlocksI)
                                        }
 
-                                       if e == nil {
+                                       if e == nil || errors.Is(e, ErrReqCreFail) {
                                                break
                                        }
                                }
@@ -190,6 +190,8 @@ func (t *Config) SwapSign(ctx context.Context, logger Logger) {
                                        w.Header().Add(header+"Error", e.Error())
                                        if errors.Is(e, ErrHeaderCheckFail) || errors.Is(e, ErrBodyCheckFail) {
                                                w.WriteHeader(http.StatusForbidden)
+                                       } else if errors.Is(e, ErrReqCreFail) {
+                                               w.WriteHeader(http.StatusServiceUnavailable)
                                        } else if errors.Is(e, ErrAllBacksFail) {
                                                w.WriteHeader(http.StatusBadGateway)
                                        } else {
diff --git a/http.go b/http.go
index d54863723872855dbd79d3bc6cda45d76faf93dc..d79b65e79f32cfc27e420639cfdef672fbd367a0 100644 (file)
--- a/http.go
+++ b/http.go
@@ -43,13 +43,10 @@ func (httpDealer) Deal(ctx context.Context, w http.ResponseWriter, r *http.Reque
 
        url = dealUri(url, chosenBack.getDealerReqUri())
 
-       reqBody, e := r.GetBody()
-       if e != nil {
-               return ErrReqCreFail
-       }
-
-       req, e := http.NewRequestWithContext(ctx, r.Method, url, reqBody)
+       req, e := http.NewRequestWithContext(ctx, r.Method, url, r.Body)
        if e != nil {
+               logger.Warn(`W:`, fmt.Sprintf(logFormat, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, "Err", e, time.Since(opT)))
+               chosenBack.Disable()
                return ErrReqCreFail
        }