From 5e533c01cb6673d8358e0bb516ee3c6eb271ec46 Mon Sep 17 00:00:00 2001 From: perp Date: Sun, 2 Jun 2024 22:09:04 +0100 Subject: [PATCH] Fix possible mutex problem (Create context > Reinsert values for handler) --- internal/context/context.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/context/context.go b/internal/context/context.go index c0d289d..9886df0 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -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