v0.0.200
This commit is contained in:
parent
adf32568ee
commit
a259bb6dbc
@ -47,6 +47,7 @@ var (
|
|||||||
TypeBindFailQuery = ErrorType{"BINDFAIL_QUERY", langext.Ptr(400)}
|
TypeBindFailQuery = ErrorType{"BINDFAIL_QUERY", langext.Ptr(400)}
|
||||||
TypeBindFailJSON = ErrorType{"BINDFAIL_JSON", langext.Ptr(400)}
|
TypeBindFailJSON = ErrorType{"BINDFAIL_JSON", langext.Ptr(400)}
|
||||||
TypeBindFailFormData = ErrorType{"BINDFAIL_FORMDATA", langext.Ptr(400)}
|
TypeBindFailFormData = ErrorType{"BINDFAIL_FORMDATA", langext.Ptr(400)}
|
||||||
|
TypeBindFailHeader = ErrorType{"BINDFAIL_HEADER", langext.Ptr(400)}
|
||||||
|
|
||||||
TypeUnauthorized = ErrorType{"UNAUTHORIZED", langext.Ptr(401)}
|
TypeUnauthorized = ErrorType{"UNAUTHORIZED", langext.Ptr(401)}
|
||||||
TypeAuthFailed = ErrorType{"AUTH_FAILED", langext.Ptr(401)}
|
TypeAuthFailed = ErrorType{"AUTH_FAILED", langext.Ptr(401)}
|
||||||
|
@ -17,6 +17,7 @@ type PreContext struct {
|
|||||||
query any
|
query any
|
||||||
body any
|
body any
|
||||||
form any
|
form any
|
||||||
|
header any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pctx *PreContext) URI(uri any) *PreContext {
|
func (pctx *PreContext) URI(uri any) *PreContext {
|
||||||
@ -39,6 +40,11 @@ func (pctx *PreContext) Form(form any) *PreContext {
|
|||||||
return pctx
|
return pctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pctx *PreContext) Header(header any) *PreContext {
|
||||||
|
pctx.header = header
|
||||||
|
return pctx
|
||||||
|
}
|
||||||
|
|
||||||
func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
||||||
if pctx.uri != nil {
|
if pctx.uri != nil {
|
||||||
if err := pctx.ginCtx.ShouldBindUri(pctx.uri); err != nil {
|
if err := pctx.ginCtx.ShouldBindUri(pctx.uri); err != nil {
|
||||||
@ -94,6 +100,16 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pctx.header != nil {
|
||||||
|
if err := pctx.ginCtx.ShouldBindHeader(pctx.query); err != nil {
|
||||||
|
err = exerr.Wrap(err, "Failed to read header").
|
||||||
|
WithType(exerr.TypeBindFailHeader).
|
||||||
|
Str("struct_type", fmt.Sprintf("%T", pctx.query)).
|
||||||
|
Build()
|
||||||
|
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ictx, cancel := context.WithTimeout(context.Background(), pctx.wrapper.requestTimeout)
|
ictx, cancel := context.WithTimeout(context.Background(), pctx.wrapper.requestTimeout)
|
||||||
actx := CreateAppContext(pctx.ginCtx, ictx, cancel)
|
actx := CreateAppContext(pctx.ginCtx, ictx, cancel)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.199"
|
const GoextVersion = "0.0.200"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2023-07-24T17:23:38+0200"
|
const GoextVersionTimestamp = "2023-07-24T17:42:18+0200"
|
||||||
|
Loading…
Reference in New Issue
Block a user