Skip to content

Commit

Permalink
ignore unknown fields request
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Jul 29, 2024
1 parent 7829c84 commit dfdc585
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions mint/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ func decodeJsonReqBody(req *http.Request, dst any) error {
}

dec := json.NewDecoder(req.Body)
// error if unknown field is specified in the json req body
dec.DisallowUnknownFields()

err := dec.Decode(&dst)
if err != nil {
Expand All @@ -537,11 +535,6 @@ func decodeJsonReqBody(req *http.Request, dst any) error {
case errors.Is(err, io.EOF):
return cashu.EmptyBodyErr

case strings.HasPrefix(err.Error(), "json: unknown field "):
invalidField := strings.TrimPrefix(err.Error(), "json: unknown field ")
msg := fmt.Sprintf("Request body contains unknown field %s", invalidField)
cashuErr = cashu.BuildCashuError(msg, cashu.StandardErrCode)

default:
cashuErr = cashu.BuildCashuError(err.Error(), cashu.StandardErrCode)
}
Expand Down

0 comments on commit dfdc585

Please sign in to comment.