lambdautils

package
v0.0.0-...-a5f7211 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Utils for making AWS Lambda & API Gateway usage easier

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InLambda

func InLambda() bool

AWS Lambda doesn't support giving argv, so we use an ugly hack to detect it

func NewLambdaHttpHandlerAdapter

func NewLambdaHttpHandlerAdapter(httpHandler http.Handler) lambda.Handler

adapts lambda.Handler to Go's http.Handler by translating between API gateway request/responses

func NewMultiEventTypeHandler

func NewMultiEventTypeHandler(fn multiEventTypeHandlerFn) lambda.Handler

func ServeApiGatewayProxyRequestUsingHttpHandler

func ServeApiGatewayProxyRequestUsingHttpHandler(
	ctx context.Context,
	proxyRequest *events.APIGatewayProxyRequest,
	httpHandler http.Handler,
) ([]byte, error)

github.com/akrylysov/algnhsa has similar implementation than apex/gateway, but had the useful bits non-exported and it used httptest for production code

Types

type LambdaHttpHandlerAdapter

type LambdaHttpHandlerAdapter struct {
	// contains filtered or unexported fields
}

higher level handler adapter. ServeApiGatewayProxyRequestUsingHttpHandler() is lower if you need to be able to give APIGatewayProxyRequest and get back byte slice & error

func (*LambdaHttpHandlerAdapter) Invoke

func (m *LambdaHttpHandlerAdapter) Invoke(ctx context.Context, payload []byte) ([]byte, error)

type NoPayloadAdapter

type NoPayloadAdapter func(context.Context) error

simple function as a Lambda handler by discarding input payload and returning empty payload. this is available in AWS's lambda.Start(handler interface{}) but it's not typesafe (runtime error if fn sig doesn't match)

func (NoPayloadAdapter) Invoke

func (s NoPayloadAdapter) Invoke(ctx context.Context, payload []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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