From f0c5b36ea97230bca18616e57be475767671e289 Mon Sep 17 00:00:00 2001 From: risqy Date: Thu, 27 Jul 2023 09:46:06 +0200 Subject: [PATCH] v0.0.213 inject gin key value pairs into context --- ginext/appContext.go | 7 +++++++ goextVersion.go | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ginext/appContext.go b/ginext/appContext.go index 564d89c..ef61442 100644 --- a/ginext/appContext.go +++ b/ginext/appContext.go @@ -14,6 +14,9 @@ type AppContext struct { } func CreateAppContext(g *gin.Context, innerCtx context.Context, cancelFn context.CancelFunc) *AppContext { + for key, value := range g.Keys { + context.WithValue(innerCtx, key, value) + } return &AppContext{ inner: innerCtx, cancelFunc: cancelFn, @@ -38,6 +41,10 @@ func (ac *AppContext) Value(key any) any { return ac.inner.Value(key) } +func (ac *AppContext) Set(key, value any) { + context.WithValue(ac.inner, key, value) +} + func (ac *AppContext) Cancel() { ac.cancelled = true ac.cancelFunc() diff --git a/goextVersion.go b/goextVersion.go index 5793344..13e0926 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.212" +const GoextVersion = "0.0.213" -const GoextVersionTimestamp = "2023-07-26T10:44:26+0200" +const GoextVersionTimestamp = "2023-07-27T09:46:06+0200"