Skip to content

Commit

Permalink
handled empty body issues #35
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Shanley <dave@quobix.com>
  • Loading branch information
daveshanley committed Dec 5, 2023
1 parent fbd40b0 commit 3685398
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions requests/validate_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ func ValidateRequestSchema(

var validationErrors []*errors.ValidationError

requestBody, _ := io.ReadAll(request.Body)
var requestBody []byte
if request != nil && request.Body != nil {
requestBody, _ = io.ReadAll(request.Body)

// close the request body, so it can be re-read later by another player in the chain
_ = request.Body.Close()
request.Body = io.NopCloser(bytes.NewBuffer(requestBody))
// close the request body, so it can be re-read later by another player in the chain
_ = request.Body.Close()
request.Body = io.NopCloser(bytes.NewBuffer(requestBody))

}

var decodedObj interface{}

if len(requestBody) > 0 {
Expand Down

0 comments on commit 3685398

Please sign in to comment.