v0.0.483
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m37s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m37s
This commit is contained in:
@@ -15,16 +15,17 @@ import (
|
||||
)
|
||||
|
||||
type PreContext struct {
|
||||
ginCtx *gin.Context
|
||||
wrapper *GinWrapper
|
||||
uri any
|
||||
query any
|
||||
body any
|
||||
rawbody *[]byte
|
||||
form any
|
||||
header any
|
||||
timeout *time.Duration
|
||||
persistantData *preContextData // must be a ptr, so that we can get the values back in out Wrap func
|
||||
ginCtx *gin.Context
|
||||
wrapper *GinWrapper
|
||||
uri any
|
||||
query any
|
||||
body any
|
||||
rawbody *[]byte
|
||||
form any
|
||||
header any
|
||||
timeout *time.Duration
|
||||
persistantData *preContextData // must be a ptr, so that we can get the values back in out Wrap func
|
||||
ignoreWrongContentType bool
|
||||
}
|
||||
|
||||
type preContextData struct {
|
||||
@@ -71,7 +72,12 @@ func (pctx *PreContext) WithSession(sessionObj SessionObject) *PreContext {
|
||||
return pctx
|
||||
}
|
||||
|
||||
func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||
func (pctx *PreContext) IgnoreWrongContentType() *PreContext {
|
||||
pctx.ignoreWrongContentType = true
|
||||
return pctx
|
||||
}
|
||||
|
||||
func (pctx PreContext) Start() (*AppContext, *gin.Context, *InspectableHTTPErrorResponse) {
|
||||
if pctx.uri != nil {
|
||||
if err := pctx.ginCtx.ShouldBindUri(pctx.uri); err != nil {
|
||||
err = exerr.Wrap(err, "Failed to read uri").
|
||||
@@ -102,10 +108,12 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
}
|
||||
} else {
|
||||
err := exerr.New(exerr.TypeBindFailJSON, "missing JSON body").
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,10 +152,12 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
}
|
||||
} else {
|
||||
err := exerr.New(exerr.TypeBindFailFormData, "missing form body").
|
||||
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
|
||||
Build()
|
||||
return nil, nil, langext.Ptr(Error(err))
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user