Hello @danslimmon, @DennyLoko, @sidbusy, @stxml, @dgsi, @kongfei605, @LeBronoMars and @tsirolnik,
First of all, sorry for delay in answering, I was just a little bit busy with university (final exams).
Regarding all the following issues (#629, #633, #636, https://github.com/danslimmon/gin/pull/1 and #661), here is what I suggest:
c.BindWith() (#661, @sidbusy), however I like the idea, so keep reading.c.ShouldBindWith() implementing #661, which will allow custom error managment.c.MustBindWith() being an alias of c.BindWith() and soft deprecating the last one (just a message via fmt.Println), for a future change of behavior, by moving c.ShouldBindWith() back to c.BindWith().Because I'm not a native english speaker, maybe the naming of the two new proposed functions sound strange or completely wrong, so I'm open to suggestion about this, and also about everything else in this message.
Hope I did explained correctly. Tell me your thoughts.
Looks good, before these, I can use binding.FormPost.Bind() instead.
Hello @javierprovecho,
These modifications LGTM. Do you need any help on them ?
I'll get back on this tomorrow
What's the status on this? Really cramping my error style.
@javierprovecho already merged #855 to develop branch so now we can use c.ShouldBindWith() which will allow custom error management.
a little question.
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
log.Println("binding called")
b := make([]byte,req.ContentLength)
log.Println("data",req.ContentLength)
log.Println(req.Body)
n,e := io.Reader(req.Body).Read(b)
if e != nil{
log.Println("read err ",e.Error(),n)
return e
}
log.Println(string(b))
e = gjson.Unmarshal(b,obj)
if e != nil{
log.Println("error unmarlshal json",e.Error())
return e
}
return nil
}
some wrong when invoke n,e := io.Reader(req.Body).Read(b)
the error just return EOF,any idea???
Most helpful comment
I'll get back on this tomorrow