Commit 27d3b1c3 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Use ReadAll

parent 7f508893
...@@ -3,7 +3,6 @@ package helper ...@@ -3,7 +3,6 @@ package helper
import ( import (
"bytes" "bytes"
"errors" "errors"
"io"
"io/ioutil" "io/ioutil"
"log" "log"
"mime" "mime"
...@@ -185,13 +184,7 @@ func ReadRequestBody(w http.ResponseWriter, r *http.Request, maxBodySize int64) ...@@ -185,13 +184,7 @@ func ReadRequestBody(w http.ResponseWriter, r *http.Request, maxBodySize int64)
limitedBody := http.MaxBytesReader(w, r.Body, maxBodySize) limitedBody := http.MaxBytesReader(w, r.Body, maxBodySize)
defer limitedBody.Close() defer limitedBody.Close()
var body bytes.Buffer return ioutil.ReadAll(limitedBody)
_, err := io.Copy(&body, limitedBody)
if err != nil {
return nil, err
}
return body.Bytes(), nil
} }
func CloneRequestWithNewBody(r *http.Request, body []byte) *http.Request { func CloneRequestWithNewBody(r *http.Request, body []byte) *http.Request {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment