package
0.0.0-20240919032739-eac131825870
Repository: https://github.com/nguyengg/golambda.git
Documentation: pkg.go.dev
# README
Lambda Function URL
package main
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/nguyengg/golambda"
"github.com/nguyengg/golambda/apigatewayhttpapi"
"github.com/nguyengg/golambda/apigatewayhttpapi/auth"
"github.com/nguyengg/golambda/apigatewayhttpapi/framework"
)
func main() {
// without a context wrapper.
apigatewayhttpapi.Start(func(ctx context.Context, request events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {
// will set LambdaContext.AwsRequestID to log prefix and reset upon completion.
defer logsupport.SetUpGlobalLogger(ctx)()
return events.APIGatewayV2HTTPResponse{
StatusCode: 200,
Body: "hello, world!",
}, nil
})
// with a context wrapper.
framework.Start(func(c *framework.Context) error {
return c.RespondOKWithText("hello, world!")
})
// authorizer example.
auth.StartV2(func(ctx context.Context, request events.APIGatewayV2CustomAuthorizerV2Request) (events.APIGatewayV2CustomAuthorizerSimpleResponse, error) {
return events.APIGatewayV2CustomAuthorizerSimpleResponse{
IsAuthorized: true,
}, nil
})
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
DisallowUnknownFields is to be used with UnmarshalRequestBodyWithOpts to disallow unknown fields in decoded JSON.
Start starts the Lambda runtime loop with the specified Handler.
StartStreaming starts the Lambda runtime loop with the specified StreamingHandler.
StartStreamingWrapper starts the Lambda runtime loop with the abstract handler.
StartWrapper starts the Lambda runtime loop with the abstract handler.
# Interfaces
Context is the context passed into the wrapped handler of Lambda Function URL requests.
HasETag allows [Context.RespondOKWithJSON] to add "ETag" header to the response.
HasLastModified allows [Context.RespondOKWithJSON] to add "Last-Modified" header to the response.
Response is a wrapper around a specific Lambda response type (events.LambdaFunctionURLResponse or events.LambdaFunctionURLStreamingResponse) with additional functionality.
# Type aliases
Handler handles requests to Lambda Function URLs in BUFFERED invoke mode.
ResponseFormatterContentType describes which format [Context.RespondFormatted] use which is JSONResponse by default.
StreamingHandler for requests to Lambda Function URLs in RESPONSE_STREAM invoke mode.