aws-lambda-go-adapter
Simple adapter for using net/http
http.Handler
with AWS Lambda.
Supports:
- AWS Lambda Function URL
- API Gateway (v1)
- API Gateway (v2)
Example
package main
import (
"github.com/aws/aws-lambda-go/lambda"
"github.com/its-felix/aws-lambda-go-adapter/httpadapter"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("pong"))
})
adapter := httpadapter.NewVanillaAdapter(mux)
handler := httpadapter.NewFunctionURLHandler(adapter)
lambda.Start(handler)
}
Extending for other frameworks
To extend this for other frameworks, you'd have to implement a new Adapter.
The adapter is responsible to translate from and to a generic http interface provided by the handler of your choice.
To get an idea, have a look at the vanilla adapter.