fix
This commit is contained in:
parent
e43e76697b
commit
28879b02fb
@ -26,7 +26,6 @@ service main {
|
||||
@server (
|
||||
prefix: api/v1/product
|
||||
group: product
|
||||
middleware: SourceInterceptor
|
||||
)
|
||||
service main {
|
||||
@handler GetProductRenderList
|
||||
|
@ -304,16 +304,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.SourceInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/render_list/:module",
|
||||
Handler: product.GetProductRenderListHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/render_list/:module",
|
||||
Handler: product.GetProductRenderListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/v1/product"),
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user