Documentation
¶
Overview ¶
Package httpadapter makes it easy to test a Golang AWS Lambda outside of AWS, without needing Docker, by providing HTTP trigger support.
See documentation: https://pkg.go.dev/github.com/Evernorth/aws-lambda-go-adapter
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(port int, handler interface{})
Start starts the HTTP server on the specified port and listens for incoming requests. When a request is received, it is converted to the appropriate Lambda event type and passed to the handler function. The response from the handler function is then converted to an HTTP response and returned to the client. See StartWithOptions for other start options.
func StartWithOptions ¶ added in v1.1.0
StartWithOptions starts the HTTP server on the specified port and listens for incoming requests. When a request is received, it is converted to the appropriate Lambda event type and passed to the handler function. The response from the handler function is then converted to an HTTP response and returned to the client.
Types ¶
type Option ¶ added in v1.1.0
type Option func(*adapterOptions)
func WithEnableSIGTERM ¶ added in v1.1.0
func WithEnableSIGTERM(sigtermFuncs ...func()) Option
WithEnableSIGTERM enables SIGTERM behavior with the HTTP server for graceful shutdown. Optionally, an array of shutdown functions to run on SIGTERM may be provided. After HTTP server graceful shutdown, the provided functions are invoked within a ~500ms timeout. If the shutdown functions do not complete within the timeout limit, a "SIGKILL" panic will occur. This enables testing in a local environment, mimicking AWS Lambda's SIGTERM and SIGKILL behavior.
Usage:
httpadapter.StartWithOptions(8080, Handler,
lambda.WithEnableSIGTERM(func() {
log.Print("Cleaning up application components...")
})
)