example

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 0 Imported by: 0

README

go-apigw-http-adapter-lambda-example

Example AWS Lambda function utilizing the harrisonhjones.com/go-apigw-http-adapter package for both HTTP and REST APIs.

Badges

  • Build: Build
  • Report Card: Go Report Card

Contributing

  1. Make changes.
  2. Add / update tests.
  3. Run make to fmt, vet, test, and build your changes.
  4. Follow the Testing steps below to deploy your changed binary to Lambda and test it.
  5. Commit your changes.
  6. Submit a PR.

Testing

Building
  1. Git clone this project.
  2. Run make. Two binaries and zip files will be created in the bin directory.
Running Locally
HTTP API
  1. Run ./bin/httpapi to
    1. Open http://localhost:8080 in your browser.
    2. You should see a web page served, an image, and a favicon (see the demo above).
REST API
  1. Run ./bin/restapi to
  2. Open http://localhost:8080/home in your browser.
  3. You should see a web page served, an image, and a favicon (see the demo above).
Deploying to Lambda and API Gateway
HTTP API
  1. Create a new AWS Lambda function using the AWS Lambda console.
    1. Make sure the Go 1.x runtime is chosen.
  2. Upload the httpapi.zip file to the Lambda function.
  3. Update the handler to be httpapi.
  4. Create a new HTTP API in the AWS API Gateway console.
  5. Set the integration to the Lambda function created earlier.
    1. Make sure the version is 2.0.
  6. Create a route with path $default.
    1. This will set the "method" to ANY.
  7. Leave all the other options as the defaults.
  8. Create the API and test it by going to INVOKEURL.
REST API
  1. Create a new AWS Lambda function using the AWS Lambda console.
    1. Make sure the Go 1.x runtime is chosen.
  2. Upload the restapi.zip file to the Lambda function.
  3. Update the handler to be restapi.
  4. Create a new REST API in the AWS API Gateway console.
  5. Create a new method set to use the Lambda function created earlier.
    1. Make sure it's setup to be a proxy integration.
  6. Set the Binary Media Types to image/*.
  7. Deploy the method using any stage name.
  8. Leave all the other options as the defaults.
  9. Create the API and test it by going to INVOKEURL/home.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Favicondotsvg = []byte{} /* 17826 elements not displayed */

Favicondotsvg represents the bytes for a gopher favicon svg image. FYI: https://golang.org/doc/gopher/favicon.svg

View Source
var Projectdotpng = []byte{} /* 8042 elements not displayed */

Projectdotpng represents the bytes for a gopher png image. FYI: https://golang.org/doc/gopher/project.png

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL