fix
This commit is contained in:
parent
e43e76697b
commit
28879b02fb
@ -26,7 +26,6 @@ service main {
|
|||||||
@server (
|
@server (
|
||||||
prefix: api/v1/product
|
prefix: api/v1/product
|
||||||
group: product
|
group: product
|
||||||
middleware: SourceInterceptor
|
|
||||||
)
|
)
|
||||||
service main {
|
service main {
|
||||||
@handler GetProductRenderList
|
@handler GetProductRenderList
|
||||||
|
@ -304,16 +304,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
rest.WithMiddlewares(
|
[]rest.Route{
|
||||||
[]rest.Middleware{serverCtx.SourceInterceptor},
|
{
|
||||||
[]rest.Route{
|
Method: http.MethodGet,
|
||||||
{
|
Path: "/render_list/:module",
|
||||||
Method: http.MethodGet,
|
Handler: product.GetProductRenderListHandler(serverCtx),
|
||||||
Path: "/render_list/:module",
|
},
|
||||||
Handler: product.GetProductRenderListHandler(serverCtx),
|
},
|
||||||
},
|
|
||||||
}...,
|
|
||||||
),
|
|
||||||
rest.WithPrefix("/api/v1/product"),
|
rest.WithPrefix("/api/v1/product"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,14 +5,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextKey string
|
|
||||||
|
|
||||||
const (
|
|
||||||
brandKey contextKey = "brand"
|
|
||||||
platformKey contextKey = "platform"
|
|
||||||
promoteKey contextKey = "promoteKey"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ReqHeaderCtxMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
func ReqHeaderCtxMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
brand := r.Header.Get("X-Brand")
|
brand := r.Header.Get("X-Brand")
|
||||||
@ -20,13 +12,13 @@ func ReqHeaderCtxMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
|||||||
promoteValue := r.Header.Get("X-Promote-Key")
|
promoteValue := r.Header.Get("X-Promote-Key")
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
if brand != "" {
|
if brand != "" {
|
||||||
ctx = context.WithValue(ctx, brandKey, brand)
|
ctx = context.WithValue(ctx, "brand", brand)
|
||||||
}
|
}
|
||||||
if platform != "" {
|
if platform != "" {
|
||||||
ctx = context.WithValue(ctx, platformKey, platform)
|
ctx = context.WithValue(ctx, "platform", platform)
|
||||||
}
|
}
|
||||||
if promoteValue != "" {
|
if promoteValue != "" {
|
||||||
ctx = context.WithValue(ctx, promoteKey, promoteValue)
|
ctx = context.WithValue(ctx, "promoteKey", promoteValue)
|
||||||
}
|
}
|
||||||
r = r.WithContext(ctx)
|
r = r.WithContext(ctx)
|
||||||
next(w, r)
|
next(w, r)
|
||||||
|
Loading…
Reference in New Issue
Block a user