Skip to content

A super simple package for converting APIGatewayProxyRequests into http.Requests in Go.

License

Notifications You must be signed in to change notification settings

clevengermatt/apiggo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

apiggo allows you to easily port your existing Go request handlers to AWS Lambda functions by eliminating the need to work directly with APIGatewayProxyRequest.

Usage

The Handler function takes an http.Handler as its first argument and so you can use any multiplexer that conforms to http.Handler. The example below is using "github.com/gorilla/mux" The second argument is the host name. You can leave this blank or put the base path you are using on your AWS API Gateway. Lastly you pass it the APIGatewayProxyRequest so it can get all of that good data from it.

package main

import (
	"fmt"
	"net/http"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/clevengermatt/apiggo"
	"github.com/gorilla/mux"
)

func main() {

	lambda.Start(func(pr events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
		router := mux.NewRouter()
		router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
			fmt.Fprint(w, "Hello, world!")
		})

		return apiggo.Handler(router, "example.com", pr)
	})
}

Built With

  • Go - The Go Programming Language
  • AWS Lambda - Libraries, samples and tools to help Go developers develop AWS Lambda functions.

Authors

See also the list of contributors who participate in this project.

About

A super simple package for converting APIGatewayProxyRequests into http.Requests in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages