Documentation ¶
Overview ¶
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS Application Load Balancer target group mode.
See lambda event detail: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#receive-event-from-load-balancer
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS API Gateway with HTTP API mode.
See lambda event detail: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS API Gateway with REST API mode.
See lambda event detail: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS API Gateway with REST API mode.
See lambda event detail: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS API Gateway with REST API mode.
See lambda event detail: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
Package aws provides an implementation using aws-sdk-go.
Lambda event type compatibility layer for AWS API Gateway with HTTP API mode.
See lambda event detail: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Index ¶
- Constants
- Variables
- func ALBTargetResponse(w *ResponseWriter, multiValue bool) (r *events.ALBTargetGroupResponse, err error)
- func ExpandJSONPath(s string, obj interface{}) string
- func ExpandPathParameters(s string, parameters map[string]string) string
- func GetALBTargetGroupRequestContext(ctx context.Context) (req *events.ALBTargetGroupRequestContext, ok bool)
- func GetProxyRequestContext(ctx context.Context) (req *events.APIGatewayProxyRequestContext, ok bool)
- func GetRawRequestContext(ctx context.Context) interface{}
- func GetStageVariables(ctx context.Context) map[string]string
- func GetV2HTTPRequestContext(ctx context.Context) (req *events.APIGatewayV2HTTPRequestContext, ok bool)
- func GetWebsocketRequestContext(ctx context.Context) (req *events.APIGatewayWebsocketProxyRequestContext, ok bool)
- func HTTPAPIResponse(w *ResponseWriter) (r *events.APIGatewayV2HTTPResponse, err error)
- func LambdaDetector() bool
- func NewALBTargetGroupRequest(ctx context.Context, e *events.ALBTargetGroupRequest) (r *http.Request, multiValue bool, err error)
- func NewHTTPAPIRequest(ctx context.Context, e *events.APIGatewayV2HTTPRequest) (r *http.Request, err error)
- func NewLambdaAdaptor(addr string, h http.Handler, options []interface{}) types.Adaptor
- func NewLambdaPassthroughRequest(ctx context.Context, payload []byte, eventPath string, contentType string) (r *http.Request, err error)
- func NewRESTAPIRequest(ctx context.Context, e *events.APIGatewayProxyRequest) (r *http.Request, multiValue bool, err error)
- func NewWebsocketRequest(ctx context.Context, e *events.APIGatewayWebsocketProxyRequest, ...) (r *http.Request, multiValue bool, err error)
- func RESTAPITargetResponse(w *ResponseWriter, multiValue bool) (r *events.APIGatewayProxyResponse, err error)
- func RouteSelector(req *events.APIGatewayWebsocketProxyRequest, expression string) (route string, err error)
- func StripBasePath(next http.Handler) http.Handler
- func WebsocketResponse(w *WebsocketResponseWriter, multiValue bool) (r *events.APIGatewayProxyResponse, err error)
- func WebsocketRouter(next http.Handler, routeExpression string) http.Handler
- type APIGatewayManagementAPI
- type HandlerFunc
- type LambdaAdaptor
- type LambdaHandler
- func (l *LambdaHandler) HandleNonHTTPEvent(ctx context.Context, event []byte, contentType string) ([]byte, error)
- func (l *LambdaHandler) Invoke(ctx context.Context, payload json.RawMessage) (res any, err error)
- func (l *LambdaHandler) InvokeALBTargetGroup(ctx context.Context, request *events.ALBTargetGroupRequest) (r *events.ALBTargetGroupResponse, err error)
- func (l *LambdaHandler) InvokeHTTPAPI(ctx context.Context, e *events.APIGatewayV2HTTPRequest) (r *events.APIGatewayV2HTTPResponse, err error)
- func (l *LambdaHandler) InvokeRESTAPI(ctx context.Context, e *events.APIGatewayProxyRequest) (r *events.APIGatewayProxyResponse, err error)
- func (l *LambdaHandler) InvokeWebsocketAPI(ctx context.Context, request *events.APIGatewayWebsocketProxyRequest) (r *events.APIGatewayProxyResponse, err error)
- func (l *LambdaHandler) ProvideAPIGatewayClient(ctx context.Context, request *events.APIGatewayWebsocketProxyRequest) (client APIGatewayManagementAPI, err error)
- type LambdaHandlerOption
- type LambdaIntegrationType
- type ResponseWriter
- type SDKConfigProvider
- type SDKSessionProvider
- type WebsocketResponseWriter
Constants ¶
const DefaultNonHTTPEventPath = "/events"
Variables ¶
var ( DefaultWebsocketPathPrefix = "websocket" DefaultRouteSelectionExpression = "$request.body.action" )
var DEBUGDumpPayload = os.Getenv("DEBUG_DUMP_PAYLOAD")
var LambdaInvokeMode = os.Getenv("LAMBDA_INVOKE_MODE")
var WebsocketResponseMode = os.Getenv("WEBSOCKET_RESPONSE_MODE")
WebsocketResponseMode * return - use lambda return value as response * post_to_connection - use PostToConnection API to send response
Functions ¶
func ALBTargetResponse ¶
func ALBTargetResponse(w *ResponseWriter, multiValue bool) (r *events.ALBTargetGroupResponse, err error)
ALBTargetResponse Response writer for Application Load Balancer target group mode.
func ExpandJSONPath ¶ added in v0.2.0
func ExpandPathParameters ¶ added in v0.4.0
func GetALBTargetGroupRequestContext ¶ added in v0.1.1
func GetALBTargetGroupRequestContext(ctx context.Context) (req *events.ALBTargetGroupRequestContext, ok bool)
func GetProxyRequestContext ¶ added in v0.1.1
func GetProxyRequestContext(ctx context.Context) (req *events.APIGatewayProxyRequestContext, ok bool)
func GetRawRequestContext ¶ added in v0.1.1
func GetStageVariables ¶ added in v0.4.1
func GetV2HTTPRequestContext ¶ added in v0.1.1
func GetV2HTTPRequestContext(ctx context.Context) (req *events.APIGatewayV2HTTPRequestContext, ok bool)
func GetWebsocketRequestContext ¶ added in v0.2.0
func GetWebsocketRequestContext(ctx context.Context) (req *events.APIGatewayWebsocketProxyRequestContext, ok bool)
func HTTPAPIResponse ¶
func HTTPAPIResponse(w *ResponseWriter) (r *events.APIGatewayV2HTTPResponse, err error)
HTTPAPIResponse Response writer for API Gateway with HTTP API mode.
func LambdaDetector ¶
func LambdaDetector() bool
func NewALBTargetGroupRequest ¶
func NewALBTargetGroupRequest(ctx context.Context, e *events.ALBTargetGroupRequest) (r *http.Request, multiValue bool, err error)
NewALBTargetGroupRequest Lambda event type to http.Request converter for Application Load Balancer target group mode.
func NewHTTPAPIRequest ¶
func NewHTTPAPIRequest(ctx context.Context, e *events.APIGatewayV2HTTPRequest) (r *http.Request, err error)
NewHTTPAPIRequest Lambda event type to http.Request converter for API Gateway with HTTP API mode.
func NewLambdaAdaptor ¶
func NewLambdaPassthroughRequest ¶ added in v0.5.0
func NewLambdaPassthroughRequest(ctx context.Context, payload []byte, eventPath string, contentType string) (r *http.Request, err error)
NewLambdaPassthroughRequest Raw lambda event type to http.Request converter.
func NewRESTAPIRequest ¶
func NewRESTAPIRequest(ctx context.Context, e *events.APIGatewayProxyRequest) (r *http.Request, multiValue bool, err error)
NewRESTAPIRequest Lambda event type to http.Request converter for API Gateway with REST API mode.
func NewWebsocketRequest ¶ added in v0.2.0
func NewWebsocketRequest(ctx context.Context, e *events.APIGatewayWebsocketProxyRequest, pathPrefix string) (r *http.Request, multiValue bool, err error)
NewWebsocketRequest Lambda event type to http.Request converter for API Gateway with REST API mode.
func RESTAPITargetResponse ¶
func RESTAPITargetResponse(w *ResponseWriter, multiValue bool) (r *events.APIGatewayProxyResponse, err error)
RESTAPITargetResponse Response writer for API Gateway with REST API mode.
func RouteSelector ¶ added in v0.2.0
func RouteSelector(req *events.APIGatewayWebsocketProxyRequest, expression string) (route string, err error)
func StripBasePath ¶ added in v0.4.0
StripBasePath Strip base path from Request path under the AWS API Gateway environment with deployment stage and API Mapping feature.
func WebsocketResponse ¶ added in v0.2.0
func WebsocketResponse(w *WebsocketResponseWriter, multiValue bool) (r *events.APIGatewayProxyResponse, err error)
WebsocketResponse Response writer for API Gateway with REST API mode.
Types ¶
type APIGatewayManagementAPI ¶ added in v0.3.0
type APIGatewayManagementAPI interface {
PostToConnection(ctx context.Context, connectionID string, data []byte) (err error)
}
func NewAPIGatewayManagementClientV1 ¶ added in v0.3.0
func NewAPIGatewayManagementClientV1(sess *session.Session, domain, stage string) APIGatewayManagementAPI
NewAPIGatewayManagementClientV1 creates a new API Gateway Management Client instance from the provided parameters. The new client will have a custom endpoint that resolves to the application's deployed API.
func NewAPIGatewayManagementClientV2 ¶ added in v0.3.0
func NewAPIGatewayManagementClientV2(conf *aws.Config, domain, stage string) APIGatewayManagementAPI
NewAPIGatewayManagementClientV2 creates a new API Gateway Management Client instance from the provided parameters. The new client will have a custom endpoint that resolves to the application's deployed API.
type HandlerFunc ¶ added in v0.7.0
type LambdaAdaptor ¶
type LambdaAdaptor struct {
// contains filtered or unexported fields
}
func (LambdaAdaptor) ListenAndServe ¶
func (l LambdaAdaptor) ListenAndServe() error
type LambdaHandler ¶
type LambdaHandler struct {
// contains filtered or unexported fields
}
func NewLambdaHandler ¶
func NewLambdaHandler(h http.Handler) *LambdaHandler
func NewLambdaHandlerWithOption ¶ added in v0.2.0
func NewLambdaHandlerWithOption(h http.Handler, options []interface{}) *LambdaHandler
func (*LambdaHandler) HandleNonHTTPEvent ¶ added in v0.5.0
func (*LambdaHandler) Invoke ¶
func (l *LambdaHandler) Invoke(ctx context.Context, payload json.RawMessage) (res any, err error)
func (*LambdaHandler) InvokeALBTargetGroup ¶
func (l *LambdaHandler) InvokeALBTargetGroup(ctx context.Context, request *events.ALBTargetGroupRequest) (r *events.ALBTargetGroupResponse, err error)
func (*LambdaHandler) InvokeHTTPAPI ¶
func (l *LambdaHandler) InvokeHTTPAPI(ctx context.Context, e *events.APIGatewayV2HTTPRequest) (r *events.APIGatewayV2HTTPResponse, err error)
func (*LambdaHandler) InvokeRESTAPI ¶
func (l *LambdaHandler) InvokeRESTAPI(ctx context.Context, e *events.APIGatewayProxyRequest) (r *events.APIGatewayProxyResponse, err error)
func (*LambdaHandler) InvokeWebsocketAPI ¶ added in v0.2.0
func (l *LambdaHandler) InvokeWebsocketAPI(ctx context.Context, request *events.APIGatewayWebsocketProxyRequest) (r *events.APIGatewayProxyResponse, err error)
func (*LambdaHandler) ProvideAPIGatewayClient ¶ added in v0.3.0
func (l *LambdaHandler) ProvideAPIGatewayClient(ctx context.Context, request *events.APIGatewayWebsocketProxyRequest) (client APIGatewayManagementAPI, err error)
type LambdaHandlerOption ¶ added in v0.2.0
type LambdaHandlerOption func(handler *LambdaHandler)
func WithAWSConfigProvider ¶ added in v0.3.0
func WithAWSConfigProvider(sp SDKConfigProvider) LambdaHandlerOption
func WithAWSSessionProvider ¶ added in v0.2.0
func WithAWSSessionProvider(sp SDKSessionProvider) LambdaHandlerOption
func WithNonHTTPEventPath ¶ added in v0.5.0
func WithNonHTTPEventPath(path string) LambdaHandlerOption
func WithoutNonHTTPEventPassThrough ¶ added in v0.5.0
func WithoutNonHTTPEventPassThrough() LambdaHandlerOption
type LambdaIntegrationType ¶
type LambdaIntegrationType int
const ( UnknownLambdaIntegrationType LambdaIntegrationType = iota APIGatewayRESTIntegration APIGatewayWebsocketIntegration APIGatewayHTTPIntegration ALBTargetGroupIntegration LambdaFunctionURLIntegration )
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter() *ResponseWriter
func (*ResponseWriter) CloseNotify ¶
func (r *ResponseWriter) CloseNotify() <-chan bool
func (*ResponseWriter) Done ¶
func (r *ResponseWriter) Done()
func (*ResponseWriter) Header ¶
func (r *ResponseWriter) Header() http.Header
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(statusCode int)
type SDKConfigProvider ¶ added in v0.3.0
type SDKSessionProvider ¶ added in v0.2.0
type WebsocketResponseWriter ¶ added in v0.2.0
type WebsocketResponseWriter struct {
// contains filtered or unexported fields
}
func NewWebsocketResponseWriter ¶ added in v0.2.0
func NewWebsocketResponseWriter(ctx context.Context, client APIGatewayManagementAPI, request *events.APIGatewayWebsocketProxyRequest) *WebsocketResponseWriter
func (*WebsocketResponseWriter) CloseNotify ¶ added in v0.2.0
func (w *WebsocketResponseWriter) CloseNotify() <-chan bool
func (*WebsocketResponseWriter) Done ¶ added in v0.2.0
func (w *WebsocketResponseWriter) Done()
func (*WebsocketResponseWriter) Header ¶ added in v0.2.0
func (w *WebsocketResponseWriter) Header() http.Header
func (*WebsocketResponseWriter) Write ¶ added in v0.2.0
func (w *WebsocketResponseWriter) Write(i []byte) (int, error)
func (*WebsocketResponseWriter) WriteHeader ¶ added in v0.2.0
func (w *WebsocketResponseWriter) WriteHeader(statusCode int)