Skip to content

Commit

Permalink
feat: binding/json invalid error
Browse files Browse the repository at this point in the history
  • Loading branch information
daheige committed Apr 18, 2022
1 parent 99cedf4 commit a8108a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions binding/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var (
// keys which do not match any non-ignored, exported fields in the destination.
EnableDecoderDisallowUnknownFields = false

// InvalidRequest request is nil or request body is nil.
InvalidRequest = errors.New("invalid request")
// ErrInvalidRequest request is nil or request body is nil.
ErrInvalidRequest = errors.New("invalid request")
)

type jsonBinding struct{}
Expand All @@ -37,8 +37,9 @@ func (jsonBinding) Name() string {

func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
if req == nil || req.Body == nil {
return InvalidRequest
return ErrInvalidRequest
}

return decodeJSON(req.Body, obj)
}

Expand Down

0 comments on commit a8108a8

Please sign in to comment.