diff --git a/src/internal/app/handler/handler.go b/src/internal/app/handler/handler.go index 2c0ce4b..b5d192d 100644 --- a/src/internal/app/handler/handler.go +++ b/src/internal/app/handler/handler.go @@ -3,7 +3,7 @@ package handler import ( "bytes" "encoding/json" - "io/ioutil" + "io" "log" "net/http" @@ -55,9 +55,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func decodeRequestData(r *http.Request, v interface{}) error { - buf, _ := ioutil.ReadAll(r.Body) - rdr := ioutil.NopCloser(bytes.NewReader(buf)) - r.Body = ioutil.NopCloser(bytes.NewReader(buf)) + buf, _ := io.ReadAll(r.Body) + rdr := io.NopCloser(bytes.NewReader(buf)) + r.Body = io.NopCloser(bytes.NewReader(buf)) json.NewDecoder(rdr).Decode(&v) diff --git a/src/internal/app/server.go b/src/internal/app/server.go index df1fdaf..cff4bc2 100644 --- a/src/internal/app/server.go +++ b/src/internal/app/server.go @@ -3,7 +3,7 @@ package app import ( "bytes" "encoding/json" - "io/ioutil" + "io" "log" "net" "net/http" @@ -63,8 +63,8 @@ func PrepareHeadersMiddleware(next http.Handler) http.Handler { func ValidateJsonBodyMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - buf, _ := ioutil.ReadAll(r.Body) - r.Body = ioutil.NopCloser(bytes.NewReader(buf)) // rollack *Request to original state + buf, _ := io.ReadAll(r.Body) + r.Body = io.NopCloser(bytes.NewReader(buf)) // rollack *Request to original state if len(buf) > 0 && !json.Valid(buf) { w.WriteHeader(http.StatusBadRequest)