16 lines
298 B
Go
16 lines
298 B
Go
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
|
|
}
|