remove bodyless check

This commit is contained in:
kevin
2020-08-12 14:44:09 +08:00
committed by kingxt
parent a26fc2b672
commit fcaebd73fb
3 changed files with 1 additions and 35 deletions

View File

@@ -34,11 +34,7 @@ func Parse(r *http.Request, v interface{}) error {
return err
}
if r.ContentLength > 0 {
return ParseJsonBody(r, v)
}
return nil
return ParseJsonBody(r, v)
}
// Parses the form request.
@@ -87,12 +83,6 @@ func ParseHeader(headerValue string) map[string]string {
// Parses the post request which contains json in body.
func ParseJsonBody(r *http.Request, v interface{}) error {
switch r.Method {
case http.MethodDelete, http.MethodPatch, http.MethodPost, http.MethodPut:
default:
return ErrBodylessRequest
}
var reader io.Reader
if withJsonBody(r) {
reader = io.LimitReader(r.Body, maxBodyLen)