Last active
February 28, 2022 09:04
-
-
Save sang-w0o/28faf303b9e7eaf02fa8a49532f64ab9 to your computer and use it in GitHub Desktop.
grpc_gateway_3.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setContextFromMetadata(ctx context.Context) (context.Context, error) { | |
md, ok := metadata.FromIncomingContext(ctx) | |
if !ok { | |
// handle error | |
} | |
data := md.Get("value1") | |
if len(data) == 0 { | |
return nil, fmt.Errorf("some error occured.") | |
} | |
value1 := data[0] | |
data = md.Get("value2") | |
if len(data) == 0 { | |
return nil, fmt.Errorf("some error occured.") | |
} | |
value2 := data[0] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment