go static-check fixes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Piotr Biernat 2022-10-06 21:56:45 +02:00
parent 62b480c873
commit fc668e633b
2 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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)