Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
danilsolovyov committed Apr 8, 2021
2 parents 8a071aa + ccd654b commit f0249fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

type Decoder struct {
json.Decoder
*json.Decoder
}

func (dec *Decoder) DecodeAndValidate(s interface{}, v Validator) error {
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func main() {
// Example 1
func UserHandler(w http.ResponseWriter, r *http.Request, v validator.Validator) {
var request RequestUser
err := json.NewDecoder(r.Body).DecodeAndValidate(&request, v)
decoder := validator.Decoder{json.NewDecoder(r.Body)}
err := decoder.DecodeAndValidate(&request, v)
if err != nil {
// ...
}
Expand Down

0 comments on commit f0249fc

Please sign in to comment.