fix: decode empty body (#1882)

status-code-override
Tony Chen 3 years ago committed by chenzhihui
parent caada1acc7
commit 29824954fa
  1. 3
      transport/http/codec.go

@ -31,6 +31,9 @@ func DefaultRequestDecoder(r *http.Request, v interface{}) error {
if err != nil { if err != nil {
return errors.BadRequest("CODEC", err.Error()) return errors.BadRequest("CODEC", err.Error())
} }
if len(data) == 0 {
return nil
}
if err = codec.Unmarshal(data, v); err != nil { if err = codec.Unmarshal(data, v); err != nil {
return errors.BadRequest("CODEC", err.Error()) return errors.BadRequest("CODEC", err.Error())
} }

Loading…
Cancel
Save