lambda

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package lambda provides a lightweight AWS API Gateway v2 ↔ net/http adapter.

It is a minimal, dependency-free bridge over the AWS Lambda Go events. ServeHTTP converts an APIGatewayV2HTTPRequest into a standard *http.Request, dispatches it to any http.Handler (e.g., a chi router), and converts the captured response back to an APIGatewayV2HTTPResponse.

Responses are written as net/http writes them. The first final status wins: later WriteHeader calls are ignored, a Write before any WriteHeader means 200, and a handler that writes nothing answers 200. An informational status other than 101 Switching Protocols is dropped, because API Gateway cannot carry an interim response. A 1xx, 204, or 304 response, or a response to a HEAD request, has no body: a Write under a 1xx, 204, or 304 status returns http.ErrBodyNotAllowed, and a Write for a HEAD request is discarded. Those 1xx, 204, and 304 responses drop Content-Length and Transfer-Encoding, and a 304 drops Content-Type too; a HEAD response keeps its headers, Content-Length included, but drops Transfer-Encoding.

Usage:

lambda.Start(func(ctx context.Context, req events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {
    return lambdahttp.ServeHTTP(ctx, req, router)
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeHTTP

ServeHTTP dispatches an APIGatewayV2HTTPRequest to handler and returns an APIGatewayV2HTTPResponse. This is the single integration point between API Gateway and a net/http handler. Errors are only returned for request conversion failures; handler panics should be caught by RecoverMiddleware.

Types

This section is empty.

Jump to

Keyboard shortcuts

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