29 lines
506 B
Go
29 lines
506 B
Go
package grpc
|
|
|
|
import (
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
type grpcMetadataCarrier struct {
|
|
md *metadata.MD
|
|
}
|
|
|
|
func (c *grpcMetadataCarrier) Get(key string) string {
|
|
values := c.md.Get(key)
|
|
if len(values) > 0 {
|
|
return values[0]
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (c *grpcMetadataCarrier) Set(key string, value string) {
|
|
c.md.Set(key, value)
|
|
}
|
|
|
|
func (c *grpcMetadataCarrier) Keys() []string {
|
|
result := make([]string, 0, c.md.Len())
|
|
for key := range *c.md {
|
|
result = append(result, key)
|
|
}
|
|
return result
|
|
}
|