gorush/vendor/github.com/apex/gateway
Bo-Yi Wu d7ce3c077c
feat(aws): support lambda (#334)
2018-01-23 16:34:34 +08:00
..
Readme.md feat(aws): support lambda (#334) 2018-01-23 16:34:34 +08:00
gateway.go feat(aws): support lambda (#334) 2018-01-23 16:34:34 +08:00
request.go feat(aws): support lambda (#334) 2018-01-23 16:34:34 +08:00
response.go feat(aws): support lambda (#334) 2018-01-23 16:34:34 +08:00

Readme.md

Package gateway provides a drop-in replacement for net/http's ListenAndServe for use in AWS Lambda & API Gateway, simply swap it out for gateway.ListenAndServe. Extracted from Up which provides additional middleware features and operational functionality.

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/apex/gateway"
)

func main() {
	addr := ":" + os.Getenv("PORT")
	http.HandleFunc("/", hello)
	log.Fatal(gateway.ListenAndServe(addr, nil))
}

func hello(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "Hello World from Go")
}

GoDoc