# README
Background
This module is intended to route AWS API Gateway proxy events for lambda functions.
Users are able to register handlers for each API resource along with an error handler and define mandatory query parameters.
If the client fails to pass required query parmeters the router will respond with the following:
{
"StatusCode" : 400,
"Body" : "endpoint requires the following query paramters: p1, p2"
}
If the client attempts to hit and resource which is not registered, the following will be returned:
{
"StatusCode" : 404
}
Example Code
func Handler(_ context.Context, r events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
// This is only an example! The router generally should be initialized once and reused!
router := New()
router.RegisterGet(
"/path",
handler.Builder().
Handler(getFunction).
ErrorHandler(errorFunction).
MandatoryQueryParameters([]string{"param1"}).
Build(),
)
event := events.APIGatewayProxyRequest{
HTTPMethod: "GET",
Resource: "/path",
}
return router.Route(event), nil
}
# Functions
No description provided by the author