httpadapter

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

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 SetLogger

func SetLogger(l *slog.Logger)

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

func StartWithOptions(port int, handler interface{}, options ...Option)

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...")
	})
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL