Created
September 19, 2019 21:57
-
-
Save webdevwilson/a09fc072e4ef09dab5d327bbd48f2e15 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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