Skip to content

Instantly share code, notes, and snippets.

@f3nry
Created February 1, 2019 01:17
Show Gist options
  • Save f3nry/8fa2ada92f96ceb904cb3974bea98576 to your computer and use it in GitHub Desktop.
Save f3nry/8fa2ada92f96ceb904cb3974bea98576 to your computer and use it in GitHub Desktop.
Second Attempt: Responding with protobuf
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