Created
February 1, 2019 01:17
-
-
Save f3nry/8fa2ada92f96ceb904cb3974bea98576 to your computer and use it in GitHub Desktop.
Second Attempt: Responding with protobuf
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 handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { | |
message := &api.AliveResponse{Message: "Hello, world."} | |
b, err := proto.Marshal(message) | |
if err != nil { | |
return events.APIGatewayProxyResponse{ | |
StatusCode: 500, | |
}, err | |
} | |
return events.APIGatewayProxyResponse{ | |
Body: base64.StdEncoding.EncodeToString(b), | |
Headers: map[string]string{ | |
"Content-Type": "application/grpc+proto", | |
"grpc-status": "0", | |
}, | |
IsBase64Encoded: true, | |
StatusCode: 200, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment