feat: req preprocessor
This commit is contained in:
@@ -16,6 +16,8 @@ type Config struct {
|
|||||||
checkKeys []string
|
checkKeys []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type contextKeyType string
|
||||||
|
|
||||||
const contextKey = "context"
|
const contextKey = "context"
|
||||||
|
|
||||||
func NewUUIDSetter(cfg *Config) (func(http.Handler) http.Handler, error) {
|
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 {
|
for _, key := range cfg.checkKeys {
|
||||||
value := uuid.NewString()
|
value := uuid.NewString()
|
||||||
updatedValue := update(contextData, key, value)
|
updatedValue := update(contextData, key, value)
|
||||||
ctx = context.WithValue(ctx, key, updatedValue)
|
ctx = context.WithValue(ctx, contextKeyType(key), updatedValue)
|
||||||
}
|
}
|
||||||
data[contextKey] = contextData
|
data[contextKey] = contextData
|
||||||
updatedBody, err := json.Marshal(data)
|
updatedBody, err := json.Marshal(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user