Merge branch 'develop'
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
1eaf6cc454
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user