Fix possible mutex problem (Create context > Reinsert values for handler)

This commit is contained in:
perp 2024-06-02 22:09:04 +01:00
parent 04f327707e
commit 5e533c01cb

View File

@ -42,10 +42,11 @@ func New(cfg *config.Config) *Context {
// Handle gin route with context
func (ctx *Context) API(handler func(ctx *Context)) func(*gin.Context) {
return func(c *gin.Context) {
ctx.Context = c
handler(ctx)
return func(gctx *gin.Context) {
context := Context{
Context: gctx,
Config: ctx.Config,
}
handler(&context)
}
}
// Todo: Check if this could cause a problem