apiggo

package module
v0.0.0-...-4ba2aa5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: Unlicense Imports: 7 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(handler http.Handler, host string, proxyRequest events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)

Handler turns an APIGatewayProxyRequest into a standard http.Request

Types

This section is empty.

Jump to

Keyboard shortcuts

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