lambda

package module
v0.0.0-...-39ac581 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package lambda provides a kind of http server emulator for lambda functions. That is an adapter which translates an incoming AWS APIGatewayProxyRequests to a regular http.Request and an outgoing http response to a AWS APIGatewayProxyResponse

The use case are http applications which should be packaged and deployed as lambda functions and possibly at the same time as a normal local executable webapplication. So appart from this adapter function the rest of the application is unaware of the fact that it runs as a lambda function.

So instead of

func main(){
	//...
	http.Serve (socket, handler)
}

for a regular http server

func main(){
	//...
	lambda.Serve (handler, logerror, loginfo)
}

can be used to serve http applications from lambda functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptorFunc

func AdaptorFunc(handler http.Handler, logerror, loginfo func(ctx context.Context, logmessage string)) func(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)

AdaptorFunc adapts a regular http.Handler to an AWS lambda handler

func AddReqIdToCtx

func AddReqIdToCtx(ctx context.Context, reqId string) context.Context

AddReqIdToCtx adds the lambda request ID to the context

func GetAliasFromRequest

func GetAliasFromRequest(req http.Request) string

func ReqIdFromCtx

func ReqIdFromCtx(ctx context.Context) (string, error)

ReqIdFromCtx reads the lambda request ID from the context

func Serve

func Serve(handler http.Handler, logerror, loginfo func(ctx context.Context, logmessage string))

Serve uses a regular http.Handler to serve AWS APIGatewayProxyRequests

Example:

func main(){
	//...
	lambda.Serve (handler, logerror, loginfo)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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