File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ func Proxy(c *gin.Context, requestConverter RequestConverter) {
3131 return
3232 }
3333
34+ // preserve request body for error logging
35+ var buf bytes.Buffer
36+ tee := io .TeeReader (c .Request .Body , & buf )
37+ bodyBytes , err := io .ReadAll (tee )
38+ if err != nil {
39+ log .Printf ("Error reading request body: %v" , err )
40+ return
41+ }
42+ c .Request .Body = io .NopCloser (& buf )
43+
3444 director := func (req * http.Request ) {
3545 if req .Body == nil {
3646 util .SendError (c , errors .New ("request body is empty" ))
@@ -102,6 +112,10 @@ func Proxy(c *gin.Context, requestConverter RequestConverter) {
102112 log .Printf ("rewrite response error: %v" , err )
103113 }
104114 }
115+
116+ if c .Writer .Status () != 200 {
117+ log .Printf ("encountering error with body: %s" , string (bodyBytes ))
118+ }
105119}
106120
107121func GetDeploymentByModel (model string ) (* DeploymentConfig , error ) {
You can’t perform that action at this time.
0 commit comments