Created
May 16, 2020 05:32
-
-
Save Kalimaha/6faf0920d033154c30e257ffbfb0e5a8 to your computer and use it in GitHub Desktop.
Go Lambda
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
package main | |
import ( | |
"encoding/json" | |
"github.com/aws/aws-lambda-go/events" | |
"github.com/aws/aws-lambda-go/lambda" | |
) | |
type MyResponse struct { | |
ResponseId string | |
} | |
// Invoke it locally | |
// aws --profile sideprojects lambda invoke --function-name RetrievePotatoes --payload '{"pathParameters": {"requestId": "42"}}' response.json | |
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { | |
requestId := request.PathParameters["requestId"] | |
response := MyResponse{ResponseId: requestId} | |
body, _ := json.Marshal(response) | |
return events.APIGatewayProxyResponse{Body: string(body), StatusCode: 200}, nil | |
} | |
func main() { | |
lambda.Start(Handler) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment