diff --git a/ginext/preContext.go b/ginext/preContext.go index bc6fc33..c6b401a 100644 --- a/ginext/preContext.go +++ b/ginext/preContext.go @@ -8,6 +8,7 @@ import ( "gogs.mikescher.com/BlackForestBytes/goext/exerr" "gogs.mikescher.com/BlackForestBytes/goext/langext" "runtime/debug" + "time" ) type PreContext struct { @@ -18,6 +19,7 @@ type PreContext struct { body any form any header any + timeout *time.Duration } func (pctx *PreContext) URI(uri any) *PreContext { @@ -45,6 +47,11 @@ func (pctx *PreContext) Header(header any) *PreContext { return pctx } +func (pctx *PreContext) WithTimeout(to time.Duration) *PreContext { + pctx.timeout = &to + return pctx +} + func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) { if pctx.uri != nil { if err := pctx.ginCtx.ShouldBindUri(pctx.uri); err != nil { @@ -118,7 +125,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) { } } - ictx, cancel := context.WithTimeout(context.Background(), pctx.wrapper.requestTimeout) + ictx, cancel := context.WithTimeout(context.Background(), langext.Coalesce(pctx.timeout, pctx.wrapper.requestTimeout)) actx := CreateAppContext(pctx.ginCtx, ictx, cancel) return actx, pctx.ginCtx, nil diff --git a/go.mod b/go.mod index 2a1ec73..5e55af2 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( ) require ( - github.com/bytedance/sonic v1.10.0-rc3 // indirect + github.com/bytedance/sonic v1.10.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect diff --git a/go.sum b/go.sum index 2609272..996ca3e 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/bytedance/sonic v1.10.0-rc2 h1:oDfRZ+4m6AYCOC0GFeOCeYqvBmucy1isvouS2K github.com/bytedance/sonic v1.10.0-rc2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/bytedance/sonic v1.10.0-rc3 h1:uNSnscRapXTwUgTyOF0GVljYD08p9X/Lbr9MweSV3V0= github.com/bytedance/sonic v1.10.0-rc3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= +github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= diff --git a/goextVersion.go b/goextVersion.go index 655c8fc..64ae6f0 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.238" +const GoextVersion = "0.0.239" -const GoextVersionTimestamp = "2023-08-09T19:51:41+0200" +const GoextVersionTimestamp = "2023-08-11T16:32:34+0200"