-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom BindWith error managing #662
Comments
Looks good, before these, I can use |
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 |
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) |
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, danslimmon#1 and #661), here is what I suggest:
c.BindWith()
(allow to custom the error handle #661, @sidbusy), however I like the idea, so keep reading.c.ShouldBindWith()
implementing allow to custom the error handle #661, which will allow custom error managment.c.MustBindWith()
being an alias ofc.BindWith()
and soft deprecating the last one (just a message viafmt.Println
), for a future change of behavior, by movingc.ShouldBindWith()
back toc.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.
The text was updated successfully, but these errors were encountered: