Skip to content

Commit

Permalink
Release (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjholm authored Aug 16, 2023
2 parents 84efe49 + 75c7669 commit aaa59fb
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cloud/aws/runtime/gateway/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,20 @@ func (s *LambdaGateway) handleApiEvent(ctx context.Context, evt events.APIGatewa
}
}

data := []byte(evt.Body)
if evt.IsBase64Encoded {
data, err = base64.StdEncoding.DecodeString(evt.Body)
if err != nil {
return events.APIGatewayProxyResponse{
StatusCode: 400,
Body: "Error processing lambda request",
IsBase64Encoded: false,
}, nil
}
}

req := &v1.TriggerRequest{
Data: []byte(evt.Body),
Data: data,
Context: &v1.TriggerRequest_Http{
Http: &v1.HttpTriggerContext{
Method: evt.RequestContext.HTTP.Method,
Expand Down Expand Up @@ -220,10 +232,9 @@ func (s *LambdaGateway) handleApiEvent(ctx context.Context, evt events.APIGatewa
responseString := base64.StdEncoding.EncodeToString(response.Data)

return events.APIGatewayProxyResponse{
StatusCode: int(response.GetHttp().Status),
Headers: lambdaHTTPHeaders,
Body: responseString,
// TODO: Need to determine best case when to use this...
StatusCode: int(response.GetHttp().Status),
Headers: lambdaHTTPHeaders,
Body: responseString,
IsBase64Encoded: true,
}, nil
}
Expand Down

0 comments on commit aaa59fb

Please sign in to comment.