fusen-gateway/server/logic/gateway_meta.go

16 lines
298 B
Go
Raw Normal View History

2023-11-16 08:24:52 +00:00
package logic
import (
"context"
"net/http"
"google.golang.org/grpc/metadata"
)
func PassMetadata(ctx context.Context, r *http.Request) metadata.MD {
headerValue := r.Header.Get("Debug-Token")
// 将值添加到 gRPC 元数据
md := metadata.Pairs("debug-token", headerValue)
return md
}