From aa10fcceaf254144621bff794ba4089028a1467a Mon Sep 17 00:00:00 2001 From: "mayur.popli" Date: Thu, 20 Mar 2025 09:03:44 +0530 Subject: [PATCH] feat: req preprocessor --- .../implementation/requestPreProcessor/reqpreprocessor.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/plugin/implementation/requestPreProcessor/reqpreprocessor.go b/shared/plugin/implementation/requestPreProcessor/reqpreprocessor.go index 177aecc..8dcb231 100644 --- a/shared/plugin/implementation/requestPreProcessor/reqpreprocessor.go +++ b/shared/plugin/implementation/requestPreProcessor/reqpreprocessor.go @@ -16,6 +16,8 @@ type Config struct { checkKeys []string } +type contextKeyType string + const contextKey = "context" func NewUUIDSetter(cfg *Config) (func(http.Handler) http.Handler, error) { @@ -49,7 +51,7 @@ func NewUUIDSetter(cfg *Config) (func(http.Handler) http.Handler, error) { for _, key := range cfg.checkKeys { value := uuid.NewString() updatedValue := update(contextData, key, value) - ctx = context.WithValue(ctx, key, updatedValue) + ctx = context.WithValue(ctx, contextKeyType(key), updatedValue) } data[contextKey] = contextData updatedBody, err := json.Marshal(data)