v0.0.484
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m58s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m58s
This commit is contained in:
@@ -77,14 +77,14 @@ func (pctx *PreContext) IgnoreWrongContentType() *PreContext {
|
||||
return pctx
|
||||
}
|
||||
|
||||
func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPErrorResponse) {
|
||||
func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||
if pctx.uri != nil {
|
||||
if err := pctx.ginCtx.ShouldBindUri(pctx.uri); err != nil {
|
||||
err = exerr.Wrap(err, "Failed to read uri").
|
||||
WithType(exerr.TypeBindFailURI).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.uri)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "URI", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
WithType(exerr.TypeBindFailQuery).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.query)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "QUERY", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,14 +105,14 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
WithType(exerr.TypeBindFailJSON).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
||||
}
|
||||
} else {
|
||||
if !pctx.ignoreWrongContentType {
|
||||
err := exerr.New(exerr.TypeBindFailJSON, "missing JSON body").
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "BODY", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,14 +121,14 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
if brc, ok := pctx.ginCtx.Request.Body.(dataext.BufferedReadCloser); ok {
|
||||
v, err := brc.BufferedAll()
|
||||
if err != nil {
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "URI", err))
|
||||
}
|
||||
*pctx.rawbody = v
|
||||
} else {
|
||||
buf := &bytes.Buffer{}
|
||||
_, err := io.Copy(buf, pctx.ginCtx.Request.Body)
|
||||
if err != nil {
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "URI", err))
|
||||
}
|
||||
*pctx.rawbody = buf.Bytes()
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
WithType(exerr.TypeBindFailFormData).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "FORM", err))
|
||||
}
|
||||
} else if pctx.ginCtx.ContentType() == "application/x-www-form-urlencoded" {
|
||||
if err := pctx.ginCtx.ShouldBindWith(pctx.form, binding.Form); err != nil {
|
||||
@@ -149,14 +149,14 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
WithType(exerr.TypeBindFailFormData).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "FORM", err))
|
||||
}
|
||||
} else {
|
||||
if !pctx.ignoreWrongContentType {
|
||||
err := exerr.New(exerr.TypeBindFailFormData, "missing form body").
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "FORM", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
WithType(exerr.TypeBindFailHeader).
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.query)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "HEADER", err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPError
|
||||
err := pctx.persistantData.sessionObj.Init(pctx.ginCtx, actx)
|
||||
if err != nil {
|
||||
actx.Cancel()
|
||||
return nil, nil, langext.Ptr(Error(exerr.Wrap(err, "Failed to init session").Build()))
|
||||
return nil, nil, langext.Ptr(pctx.wrapper.buildRequestBindError(pctx.ginCtx, "INIT", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user