alb

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: MIT Imports: 9 Imported by: 0

README

Package alb provides adapter enabling usage of http.Handler inside AWS
Lambda running behind AWS ALB as described here:
https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html

Usage example:

    package main

    import (
    	"fmt"
    	"net/http"

    	"github.com/artyom/alb"
    	"github.com/aws/aws-lambda-go/lambda"
    )

    func main() { lambda.Start(alb.Handler(http.HandlerFunc(hello))) }

    func hello(w http.ResponseWriter, r *http.Request) {
    	fmt.Fprintln(w, "Hello from AWS Lambda behind ALB")
    }

See documentation at https://godoc.org/github.com/artyom/alb

Documentation

Overview

Package alb provides adapter enabling usage of http.Handler inside AWS Lambda running behind AWS ALB as described here: https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html

Usage example:

package main

import (
	"fmt"
	"net/http"

	"github.com/artyom/alb"
	"github.com/aws/aws-lambda-go/lambda"
)

func main() { lambda.Start(alb.Handler(http.HandlerFunc(hello))) }

func hello(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "Hello from AWS Lambda behind ALB")
}

Note: since both request and reply to/from AWS Lambda are passed as json-encoded payloads, their sizes are limited. AWS documentation states that: "The maximum size of the request body that you can send to a Lambda function is 1 MB. [...] The maximum size of the response JSON that the Lambda function can send is 1 MB." Exact limit of response size also depends on whether its body is valid utf8 or not, as non-utf8 payloads are transparently base64-encoded, which adds some overhead.

For further details see https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(h http.Handler) func(context.Context, request) (*response, error)

Handler returns function suitable to use as an AWS Lambda handler with github.com/aws/aws-lambda-go/lambda package.

Note that request is fully cached in memory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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