directory
Version:
v0.1.0-alpha
Opens a new window with list of versions in this module.
Published: Jul 22, 2024
License: Apache-2.0
Opens a new window with license information.
README
¶
Usages:
function-url-router
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
router "github.com/rthing31/go/aws-lambda/function-url-router"
)
func main() {
r := router.NewRouter()
// Register custom handler for different endpoints and methods
r.AddRoute(router.MethodGet, "/custom", CustomHandler{})
// Start the Lambda handler
lambda.Start(r.HandleRequest)
}
// CustomHandler is a user-defined handler
type CustomHandler struct{}
// HandleRequest handles the request
func (h CustomHandler) HandleRequest(ctx context.Context, request events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) {
return events.LambdaFunctionURLResponse{
StatusCode: 200,
Body: fmt.Sprintf("Handled custom request at %s", request.RawPath),
}, nil
}
Directories
¶
Click to show internal directories.
Click to hide internal directories.