fix
This commit is contained in:
@@ -5,14 +5,6 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
const (
|
||||
brandKey contextKey = "brand"
|
||||
platformKey contextKey = "platform"
|
||||
promoteKey contextKey = "promoteKey"
|
||||
)
|
||||
|
||||
func ReqHeaderCtxMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
brand := r.Header.Get("X-Brand")
|
||||
@@ -20,13 +12,13 @@ func ReqHeaderCtxMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
promoteValue := r.Header.Get("X-Promote-Key")
|
||||
ctx := r.Context()
|
||||
if brand != "" {
|
||||
ctx = context.WithValue(ctx, brandKey, brand)
|
||||
ctx = context.WithValue(ctx, "brand", brand)
|
||||
}
|
||||
if platform != "" {
|
||||
ctx = context.WithValue(ctx, platformKey, platform)
|
||||
ctx = context.WithValue(ctx, "platform", platform)
|
||||
}
|
||||
if promoteValue != "" {
|
||||
ctx = context.WithValue(ctx, promoteKey, promoteValue)
|
||||
ctx = context.WithValue(ctx, "promoteKey", promoteValue)
|
||||
}
|
||||
r = r.WithContext(ctx)
|
||||
next(w, r)
|
||||
|
||||
Reference in New Issue
Block a user