fix missing error on missing json header
This commit is contained in:
parent
3888c91a6b
commit
d396a12d68
@ -239,15 +239,23 @@ func (app *Application) StartRequest(g *gin.Context, uri any, query any, body an
|
||||
}
|
||||
}
|
||||
|
||||
if body != nil && g.ContentType() == "application/json" {
|
||||
if body != nil {
|
||||
if g.ContentType() == "application/json" {
|
||||
if err := g.ShouldBindJSON(body); err != nil {
|
||||
return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read body", err))
|
||||
return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "Failed to read body", err))
|
||||
}
|
||||
} else {
|
||||
return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "missing JSON body", nil))
|
||||
}
|
||||
}
|
||||
|
||||
if form != nil && g.ContentType() == "multipart/form-data" {
|
||||
if form != nil {
|
||||
if g.ContentType() == "multipart/form-data" {
|
||||
if err := g.ShouldBindWith(form, binding.Form); err != nil {
|
||||
return nil, langext.Ptr(ginresp.APIError(g, 400, apierr.BINDFAIL_BODY_PARAM, "Failed to read multipart-form", err))
|
||||
return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailFormData, "Failed to read multipart-form", err))
|
||||
}
|
||||
} else {
|
||||
return nil, langext.Ptr(ginresp.APIError(g, apierr.BindFailJSON, "missing form body", nil))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user