goserverlessapi

package module
v0.0.0-...-168b073 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: MIT Imports: 1 Imported by: 0

README

Build Status Go Report Card

go-serverless-api

  • Boilerplate Golang API
  • AWS Severless Application Model (SAM) Deployment to AWS Lambda & API Gateway

Deploy to AWS

1. Build and package into a zip
$ make bundle-lambda
2. Upload zip to AWS S3 & create updated SAM template (packaged-template.yaml)
$ aws s3 mb s3://my-bucket

$ aws cloudformation package \
    --template-file template.yaml \
    --s3-bucket my-bucket \
    --output-template-file packaged-template.yaml
2. Deploy to AWS Lambda & API Gateway with updated SAM template
$ aws cloudformation deploy \
    --template-file packaged-template.yaml \
    --stack-name go-serverless-api-stack \
    --capabilities CAPABILITY_IAM
3. Test

AWS API Gateway addresses take the following format.

https://<api-rest-id>.execute-api.<your-aws-region>.amazonaws.com/<api-stage>
$ aws apigateway get-rest-apis
{
    "items": [
        {
            "id": "0qu18x8pyd",
            "name": "go-serverless-api-stack",
            "createdDate": 1523987269,
            "version": "1.0",
            "apiKeySource": "HEADER",
            "endpointConfiguration": {
                "types": [
                    "EDGE"
                ]
            }
        }
    ]
}
$ curl -s https://0qu18x8pyd.execute-api.eu-west-1.amazonaws.com/Stage/healthz
ok
$ curl -s https://0qu18x8pyd.execute-api.eu-west-1.amazonaws.com/Prod/healthz
ok
4. Delete Stack
$ aws cloudformation delete-stack \
	--stack-name go-serverless-api-stack

Local Development

Build & Run API
$ make run
Manually call APi
$ make test-run

Tests

$ go test ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthHandler

func HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler is an endpoint for healthchecks

Types

This section is empty.

Jump to

Keyboard shortcuts

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