Skip to content

Commit

Permalink
fix mholt#57
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Luis Panuto Silva committed Aug 8, 2019
1 parent f4f5845 commit daed47a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/url"
"os"

"github.com/mholt/binding"
"github.com/nubunto/binding"
)

type MyBinder map[string]string
Expand Down
24 changes: 13 additions & 11 deletions binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,21 @@ var multipartFormBinder requestBinder = defaultMultipartFormBinder
func defaultMultipartFormBinder(req *http.Request, userStruct FieldMapper) Errors {
var errs Errors

multipartReader, err := req.MultipartReader()
if err != nil {
errs.Add([]string{}, DeserializationError, err.Error())
return errs
}
if req.MultipartForm == nil {
multipartReader, err := req.MultipartReader()
if err != nil {
errs.Add([]string{}, DeserializationError, err.Error())
return errs
}

form, parseErr := multipartReader.ReadForm(MaxMemory)
if parseErr != nil {
errs.Add([]string{}, DeserializationError, parseErr.Error())
return errs
}
form, parseErr := multipartReader.ReadForm(MaxMemory)
if parseErr != nil {
errs.Add([]string{}, DeserializationError, parseErr.Error())
return errs
}

req.MultipartForm = form
req.MultipartForm = form
}

return bindForm(req, userStruct, req.MultipartForm.Value, req.MultipartForm.File)
}
Expand Down
2 changes: 1 addition & 1 deletion fieldbinder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"
"strconv"

"github.com/mholt/binding"
"github.com/nubunto/binding"
)

type MyType struct {
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/nubunto/binding

go 1.12

require github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

0 comments on commit daed47a

Please sign in to comment.