Add random delay and errors middleware

This commit is contained in:
Stefan Prodan
2018-08-21 03:12:20 +03:00
parent 0f098cf0f1
commit 593ccaa0cd
4 changed files with 39 additions and 2 deletions
+2 -2
View File
@@ -5,6 +5,7 @@ import (
"context"
"io/ioutil"
"net/http"
"github.com/stefanprodan/k8s-podinfo/pkg/version"
"go.uber.org/zap"
)
@@ -16,6 +17,7 @@ func (s *Server) echoHandler(w http.ResponseWriter, r *http.Request) {
s.ErrorResponse(w, r, "invalid request body", http.StatusBadRequest)
return
}
defer r.Body.Close()
if len(s.config.BackendURL) > 0 {
backendReq, err := http.NewRequest("POST", s.config.BackendURL, bytes.NewReader(body))
@@ -75,5 +77,3 @@ func (s *Server) echoHandler(w http.ResponseWriter, r *http.Request) {
w.Write(body)
}
}