Class ApiGatewayV2Router

Routes API Gateway HTTP API and Lambda Function URL Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest instances through a NanoRoute pipeline.

Inheritance
object
Router
Router<ApiGatewayV2Router, ApiGatewayV2RouterConfig>
ApiGatewayV2Router
Inherited Members
Router<ApiGatewayV2Router, ApiGatewayV2RouterConfig>.CreateBuilder()
Router<ApiGatewayV2Router, ApiGatewayV2RouterConfig>.Config
Router.TraceIdName
Router.OriginalRequestName
Router.Config
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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 request or services is null.

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.

In this article
Back to top Generated by DocFX