v0.0.546 Fix ginext json-parse error when the bufferedReader was read beforehand
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m55s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m55s
This commit is contained in:
@@ -100,6 +100,17 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||
|
||||
if pctx.body != nil {
|
||||
if pctx.ginCtx.ContentType() == "application/json" {
|
||||
if brc, ok := pctx.body.(dataext.BufferedReadCloser); ok {
|
||||
// Ensures a fully reset (offset=0) buffer before parsing
|
||||
err := brc.Reset()
|
||||
if err != nil {
|
||||
err = exerr.Wrap(err, "Failed to read (brc.reset) json-body").
|
||||
WithType(exerr.TypeBindFailJSON).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "JSON", err))
|
||||
}
|
||||
}
|
||||
if err := pctx.ginCtx.ShouldBindJSON(pctx.body); err != nil {
|
||||
err = exerr.Wrap(err, "Failed to read json-body").
|
||||
WithType(exerr.TypeBindFailJSON).
|
||||
|
Reference in New Issue
Block a user