lambdaurl

package
v1.51.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 12

Documentation

Overview

Package lambdaurl serves requests from Lambda Function URLs using http.Handler.

This package allows you to use standard Go http.Handler implementations with Lambda Function URLs, making it easy to adapt existing HTTP applications to run on Lambda.

See https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html

Package lambdaurl serves requests from Lambda Function URLs using http.Handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestFromContext

func RequestFromContext(ctx context.Context) (*events.LambdaFunctionURLRequest, bool)

RequestFromContext returns the *events.LambdaFunctionURLRequest from a context.

func Start

func Start(handler http.Handler, options ...lambda.Option)

Start wraps a http.Handler and calls lambda.StartHandlerFunc Only supports:

  • Lambda Function URLs configured with `InvokeMode: RESPONSE_STREAM`
  • Lambda Functions using the `provided` or `provided.al2` runtimes.
  • Lambda Functions using the `go1.x` runtime when compiled with `-tags lambda.norpc`

func WithDetectContentType added in v1.42.0

func WithDetectContentType(detectContentType bool) lambda.Option

WithDetectContentType sets the behavior of content type detection when the Content-Type header is not already provided. When true, the first Write call will pass the intial bytes to http.DetectContentType. When false, and if no Content-Type is provided, no Content-Type will be sent back to Lambda, and the Lambda Function URL will fallback to it's default.

Note: The http.ResponseWriter passed to the handler is unbuffered. This may result in different Content-Type headers in the Function URL response when compared to http.ListenAndServe.

Usage:

lambdaurl.Start(
        http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
                w.Write("<!DOCTYPE html><html></html>")
        }),
        lambdaurl.WithDetectContentType(true)
)

func Wrap

Wrap converts an http.Handler into a Lambda request handler.

Only Lambda Function URLs configured with `InvokeMode: RESPONSE_STREAM` are supported with the returned handler. The response body of the handler will conform to the content-type `application/vnd.awslambda.http-integration-response`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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