Skip to content

Commit

Permalink
implement New function to return lambda.Handler from http.Handler (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
acoover committed Dec 29, 2023
1 parent 8c3f649 commit 994f8c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions adapter.go
Expand Up @@ -10,6 +10,19 @@ import (
"github.com/aws/aws-lambda-go/lambda"
)

// New returns a new lambda handler for the given http.Handler.
// It is up to the caller of New to run lamdba.Start(handler) with the returned handler.
func New(handler http.Handler, opts *Options) lambda.Handler {
if handler == nil {
handler = http.DefaultServeMux
}
if opts == nil {
opts = defaultOptions
}
opts.setBinaryContentTypeMap()
return lambdaHandler{httpHandler: handler, opts: opts}
}

var defaultOptions = &Options{}

type lambdaHandler struct {
Expand Down

0 comments on commit 994f8c8

Please sign in to comment.