2018-07-25 22:28:26 +00:00
|
|
|
# lambdarouter
|
2019-04-07 22:22:26 +00:00
|
|
|
[![GoDoc Reference](https://godoc.org/github.com/mitchell/lambdarouter?status.svg)](https://godoc.org/github.com/mitchell/lambdarouter)
|
2019-02-07 03:39:58 +00:00
|
|
|
[![Build Status](https://travis-ci.org/mitchell/lambdarouter.svg?branch=master)](https://travis-ci.org/mitchell/lambdarouter)
|
2018-07-26 01:53:26 +00:00
|
|
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/7270c6c4017b36d07360/test_coverage)](https://codeclimate.com/github/mitchelljfs/lambdarouter/test_coverage)
|
|
|
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7270c6c4017b36d07360/maintainability)](https://codeclimate.com/github/mitchelljfs/lambdarouter/maintainability)
|
2019-04-07 22:22:26 +00:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/mitchell/lambdarouter)](https://goreportcard.com/report/github.com/mitchell/lambdarouter)
|
2018-07-25 22:28:26 +00:00
|
|
|
|
2019-04-07 22:22:26 +00:00
|
|
|
This package contains a router capable of routing many AWS Lambda API gateway requests to anything
|
|
|
|
that implements the aws-lambda-go/lambda.Handler interface, all in one Lambda function. It plays
|
|
|
|
especially well with go-kit's awslambda transport package. Get started by reading below and visiting
|
|
|
|
the [GoDoc reference](https://godoc.org/github.com/mitchell/lambdarouter).
|
|
|
|
|
|
|
|
## Initializing a Router
|
|
|
|
```
|
|
|
|
r := lambdarouter.New("prefix/")
|
|
|
|
|
|
|
|
r.Get("hello/{name}", helloHandler)
|
|
|
|
r.Post("hello/server", helloHandler)
|
|
|
|
r.Delete("hello", lambda.NewHandler(func() (events.APIGatewayProxyResponse, error) {
|
|
|
|
return events.APIGatewayProxyResponse{
|
|
|
|
Body: "nothing to delete",
|
|
|
|
}, nil
|
|
|
|
}))
|
|
|
|
|
|
|
|
lambda.StartHandler(r)
|
|
|
|
```
|
|
|
|
|
|
|
|
Check out the `examples/` folder for more fleshed out examples in the proper context.
|