You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
309 B
18 lines
309 B
package meta |
|
|
|
import ( |
|
"context" |
|
"google.golang.org/grpc/metadata" |
|
) |
|
|
|
func GetUid(ctx context.Context, key string) (string, bool) { |
|
md, ok := metadata.FromIncomingContext(ctx) |
|
if !ok { |
|
return "", false |
|
} |
|
vals := md.Get(key) |
|
if len(vals) == 0 { |
|
return "", false |
|
} |
|
return vals[len(vals)-1], true |
|
}
|
|
|