implement statuscode in packets
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 2m2s

This commit is contained in:
matst80
2024-11-11 23:24:03 +01:00
parent 9c15251f67
commit 0b290a32bf
17 changed files with 295 additions and 226 deletions

View File

@@ -52,11 +52,16 @@ func ErrorHandler(fn func(w http.ResponseWriter, r *http.Request) error) func(w
}
}
func (s *PoolServer) WriteResult(w http.ResponseWriter, data []byte) error {
func (s *PoolServer) WriteResult(w http.ResponseWriter, result *CallResult) error {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("X-Pod-Name", s.pod_name)
if result.StatusCode != 200 {
w.WriteHeader(int(result.StatusCode))
w.Write([]byte(result.Data))
return nil
}
w.WriteHeader(http.StatusOK)
_, err := w.Write(data)
_, err := w.Write(result.Data)
return err
}