Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b9d0348735
|
|||
b9e9575b9b
|
@@ -163,16 +163,16 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
|
|||||||
|
|
||||||
ictx, cancel := context.WithTimeout(context.Background(), langext.Coalesce(pctx.timeout, pctx.wrapper.requestTimeout))
|
ictx, cancel := context.WithTimeout(context.Background(), langext.Coalesce(pctx.timeout, pctx.wrapper.requestTimeout))
|
||||||
|
|
||||||
|
actx := CreateAppContext(pctx.ginCtx, ictx, cancel)
|
||||||
|
|
||||||
if pctx.persistantData.sessionObj != nil {
|
if pctx.persistantData.sessionObj != nil {
|
||||||
err := pctx.persistantData.sessionObj.Init(pctx.ginCtx, ictx)
|
err := pctx.persistantData.sessionObj.Init(pctx.ginCtx, actx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
actx.Cancel()
|
||||||
return nil, nil, langext.Ptr(Error(exerr.Wrap(err, "Failed to init session").Build()))
|
return nil, nil, langext.Ptr(Error(exerr.Wrap(err, "Failed to init session").Build()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actx := CreateAppContext(pctx.ginCtx, ictx, cancel)
|
|
||||||
|
|
||||||
return actx, pctx.ginCtx, nil
|
return actx, pctx.ginCtx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SessionObject interface {
|
type SessionObject interface {
|
||||||
Init(g *gin.Context, ctx context.Context) error
|
Init(g *gin.Context, ctx *AppContext) error
|
||||||
Finish(ctx context.Context, resp HTTPResponse) error
|
Finish(ctx context.Context, resp HTTPResponse) error
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.377"
|
const GoextVersion = "0.0.379"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-01-14T17:06:42+0100"
|
const GoextVersionTimestamp = "2024-01-19T17:30:20+0100"
|
||||||
|
21
langext/must.go
Normal file
21
langext/must.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package langext
|
||||||
|
|
||||||
|
// Must returns a value and panics on error
|
||||||
|
//
|
||||||
|
// Usage: Must(methodWithError(...))
|
||||||
|
func Must[T any](v T, err error) T {
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustBool returns a value and panics on missing
|
||||||
|
//
|
||||||
|
// Usage: MustBool(methodWithOkayReturn(...))
|
||||||
|
func MustBool[T any](v T, ok bool) T {
|
||||||
|
if !ok {
|
||||||
|
panic("not ok")
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
Reference in New Issue
Block a user