Skip to content

Commit 2a03263

Browse files
committed
handled empty body issues #35
Signed-off-by: Dave Shanley <[email protected]>
1 parent fbd40b0 commit 2a03263

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

requests/validate_request.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ func ValidateRequestSchema(
3333

3434
var validationErrors []*errors.ValidationError
3535

36-
requestBody, _ := io.ReadAll(request.Body)
36+
var requestBody []byte
37+
if request != nil && request.Body != nil {
38+
requestBody, _ = io.ReadAll(request.Body)
3739

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

44+
}
45+
4246
var decodedObj interface{}
4347

4448
if len(requestBody) > 0 {

0 commit comments

Comments
 (0)