Skip to content

Instantly share code, notes, and snippets.

@webdevwilson
Created September 19, 2019 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdevwilson/a09fc072e4ef09dab5d327bbd48f2e15 to your computer and use it in GitHub Desktop.
Save webdevwilson/a09fc072e4ef09dab5d327bbd48f2e15 to your computer and use it in GitHub Desktop.
func HandleRequest(ctx context.Context, apiGatewayReq events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
// Create the handler
pathPrefix := fmt.Sprintf("/%s", apiGatewayReq.RequestContext.Stage)
handler := boundary.NewRequestHandler(pathPrefix)
// Create an HTTP request from the event
req, err := getRequestFromLambda(apiGatewayReq)
if err != nil {
return events.APIGatewayProxyResponse{}, err
}
resp := newLambdaResponseWriter()
handler.ServeHTTP(resp, req)
// Return the lambda response event
response := events.APIGatewayProxyResponse{
StatusCode: resp.statusCode,
Body: string(resp.body),
Headers: resp.flattenHeaders(),
}
return response, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment