Update json.go

This commit is contained in:
nimrodishi 2024-01-10 12:22:30 +02:00 committed by GitHub
parent 38af58eb9b
commit db282b84cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,12 @@ func (jsonBinding) Bind(req *http.Request, obj any) error {
if req == nil || req.Body == nil { if req == nil || req.Body == nil {
return errors.New("invalid request") return errors.New("invalid request")
} }
if req.GetBody == nil {
req.GetBody = func()(io.ReadCloser, error) {
var readerCopy io.ReadCloser = req.Body
return readerCopy, nil
}
}
body, err := req.GetBody() body, err := req.GetBody()
if err != nil { if err != nil {
return err return err