|
|
@@ -105,14 +105,14 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
|
|
|
WithType(exerr.TypeBindFailJSON).
|
|
|
|
WithType(exerr.TypeBindFailJSON).
|
|
|
|
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
|
|
|
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
|
|
|
Build()
|
|
|
|
Build()
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "JSON", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if !pctx.ignoreWrongContentType {
|
|
|
|
if !pctx.ignoreWrongContentType {
|
|
|
|
err := exerr.New(exerr.TypeBindFailJSON, "missing JSON body").
|
|
|
|
err := exerr.New(exerr.TypeBindFailJSON, "missing JSON body").
|
|
|
|
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
|
|
|
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
|
|
|
Build()
|
|
|
|
Build()
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "JSON", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -121,14 +121,14 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
|
|
|
if brc, ok := pctx.ginCtx.Request.Body.(dataext.BufferedReadCloser); ok {
|
|
|
|
if brc, ok := pctx.ginCtx.Request.Body.(dataext.BufferedReadCloser); ok {
|
|
|
|
v, err := brc.BufferedAll()
|
|
|
|
v, err := brc.BufferedAll()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "URI", err))
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*pctx.rawbody = v
|
|
|
|
*pctx.rawbody = v
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
buf := &bytes.Buffer{}
|
|
|
|
buf := &bytes.Buffer{}
|
|
|
|
_, err := io.Copy(buf, pctx.ginCtx.Request.Body)
|
|
|
|
_, err := io.Copy(buf, pctx.ginCtx.Request.Body)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "URI", err))
|
|
|
|
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*pctx.rawbody = buf.Bytes()
|
|
|
|
*pctx.rawbody = buf.Bytes()
|
|
|
|
}
|
|
|
|
}
|
|
|
|