Example AWS Lambda function utilizing the harrisonhjones.com/go-apigw-http-adapter package for both HTTP and REST APIs.
- Make changes.
- Add / update tests.
- Run
make
to fmt, vet, test, and build your changes. - Follow the Testing steps below to deploy your changed binary to Lambda and test it.
- Commit your changes.
- Submit a PR.
- Git clone this project.
- Run
make
. Two binaries and zip files will be created in thebin
directory.
- Run
./bin/httpapi
to- Open http://localhost:8080 in your browser.
- You should see a web page served, an image, and a favicon (see the demo above).
- Run
./bin/restapi
to - Open http://localhost:8080/home in your browser.
- You should see a web page served, an image, and a favicon (see the demo above).
- Create a new AWS Lambda function using the AWS Lambda console.
- Make sure the
Go 1.x
runtime is chosen.
- Make sure the
- Upload the
httpapi.zip
file to the Lambda function. - Update the handler to be
httpapi
. - Create a new HTTP API in the AWS API Gateway console.
- Set the integration to the Lambda function created earlier.
- Make sure the version is
2.0
.
- Make sure the version is
- Create a route with path
$default
.- This will set the "method" to
ANY
.
- This will set the "method" to
- Leave all the other options as the defaults.
- Create the API and test it by going to
INVOKEURL
.
- Create a new AWS Lambda function using the AWS Lambda console.
- Make sure the
Go 1.x
runtime is chosen.
- Make sure the
- Upload the
restapi.zip
file to the Lambda function. - Update the handler to be
restapi
. - Create a new REST API in the AWS API Gateway console.
- Create a new method set to use the Lambda function created earlier.
- Make sure it's setup to be a proxy integration.
- Set the
Binary Media Types
toimage/*
. - Deploy the method using any stage name.
- Leave all the other options as the defaults.
- Create the API and test it by going to
INVOKEURL/home
.