Documentation
¶
Overview ¶
Package awslambda provides an adapter that bridges protosource's provider-agnostic handlers to AWS API Gateway Lambda proxy integration.
Index ¶
- func Auth0Extractor(request events.APIGatewayProxyRequest) string
- func CognitoExtractor(request events.APIGatewayProxyRequest) string
- func CustomAuthExtractor(request events.APIGatewayProxyRequest) string
- func IAMExtractor(request events.APIGatewayProxyRequest) string
- func OktaExtractor(request events.APIGatewayProxyRequest) string
- func Wrap(handler protosource.HandlerFunc, extractor ActorExtractor) ...
- func WrapRouter(router *protosource.Router, extractor ActorExtractor) ...
- type ActorExtractor
- type Adapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth0Extractor ¶
func Auth0Extractor(request events.APIGatewayProxyRequest) string
Auth0Extractor extracts the actor from an Auth0 JWT authorizer. Auth0 uses the standard "sub" claim in the JWT, which API Gateway passes through the authorizer context.
func CognitoExtractor ¶
func CognitoExtractor(request events.APIGatewayProxyRequest) string
CognitoExtractor extracts the actor from a Cognito User Pool JWT authorizer. It reads the "sub" claim from the authorizer context.
func CustomAuthExtractor ¶
func CustomAuthExtractor(request events.APIGatewayProxyRequest) string
CustomAuthExtractor extracts the actor from a custom/Lambda authorizer. It reads the "principalId" field from the authorizer context.
func IAMExtractor ¶
func IAMExtractor(request events.APIGatewayProxyRequest) string
IAMExtractor extracts the actor from IAM authorization. It returns the caller's ARN from the request identity.
func OktaExtractor ¶
func OktaExtractor(request events.APIGatewayProxyRequest) string
OktaExtractor extracts the actor from an Okta JWT authorizer. Okta uses the "uid" claim for the user identifier.
func Wrap ¶
func Wrap(handler protosource.HandlerFunc, extractor ActorExtractor) func(context.Context, events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Wrap is a convenience function that returns the Handle method directly, suitable for passing to lambda.Start().
func WrapRouter ¶
func WrapRouter(router *protosource.Router, extractor ActorExtractor) func(context.Context, events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
WrapRouter returns a Lambda handler that dispatches to the router based on the request's HTTP method and path. Suitable for passing to lambda.Start().
Types ¶
type ActorExtractor ¶
type ActorExtractor func(events.APIGatewayProxyRequest) string
ActorExtractor extracts the actor identity from an API Gateway request. Return an empty string if no identity can be determined.
func Chain ¶
func Chain(extractors ...ActorExtractor) ActorExtractor
Chain returns an ActorExtractor that tries each extractor in order, returning the first non-empty result. This is useful when your API supports multiple authentication methods (e.g., Cognito for end users, IAM for service-to-service calls).
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter wraps a protosource.HandlerFunc with AWS API Gateway conversion and actor extraction.
func New ¶
func New(handler protosource.HandlerFunc, extractor ActorExtractor) *Adapter
New creates an Adapter that converts API Gateway requests to protosource requests, extracts the actor using the provided extractor, and converts the protosource response back to an API Gateway response.
func (*Adapter) Handle ¶
func (a *Adapter) Handle(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Handle is the Lambda entry point. Pass this to lambda.Start().