feat: req preprocessor

This commit is contained in:
mayur.popli
2025-03-20 09:03:44 +05:30
parent bc316ed39f
commit aa10fcceaf

View File

@@ -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)