Class ApiGatewayV2Router
Routes API Gateway HTTP API and Lambda Function URL Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest instances through a NanoRoute pipeline.
Inherited Members
Namespace: NanoRoute.AwsLambda
Assembly: NanoRoute.AwsLambda.dll
Syntax
public sealed class ApiGatewayV2Router : Router<ApiGatewayV2Router, ApiGatewayV2RouterConfig>
Examples
ApiGatewayV2Router router = ApiGatewayV2Router
.CreateBuilder()
.AddJsonErrorDetails()
.AddDefaultValueParsers()
.AddHandler("GET", "/health/", (context, _) => HttpResponseMessage.Json(new { status = "ok" }))
.CreateRouter();
Methods
Route(APIGatewayHttpApiV2ProxyRequest, IServiceProvider, TimeSpan)
Routes an API Gateway HTTP API or Lambda Function URL payload-format-2.0 request and returns the corresponding proxy response.
Declaration
public Task<APIGatewayHttpApiV2ProxyResponse> Route(APIGatewayHttpApiV2ProxyRequest request, IServiceProvider services, TimeSpan remainingTime)
Parameters
| Type | Name | Description |
|---|---|---|
| APIGatewayHttpApiV2ProxyRequest | request | The API Gateway v2 request event. |
| IServiceProvider | services | The service provider exposed to handlers through Services. |
| TimeSpan | remainingTime | The time left before the Lambda invocation times out. Expired execution produces a response with GatewayTimeout status. |
Returns
| Type | Description |
|---|---|
| Task<APIGatewayHttpApiV2ProxyResponse> | The API Gateway v2 proxy response generated by NanoRoute. |
Examples
APIGatewayHttpApiV2ProxyResponse response = await router.Route(request, services, context.RemainingTime);
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
| ArgumentException | Thrown when the request uses an unsupported HTTP method. |
| InvalidOperationException | Thrown when the API Gateway request does not contain a recognizable URI. |
| HttpRequestException | Thrown when no handler matches the request path or a matched handler signals an HTTP failure that is not translated by middleware. |