Class ApiGatewayV2Router

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

Inheritance
object
RouterBase<ApiGatewayV2RouterConfig>
ApiGatewayV2Router
Inherited Members
RouterBase<ApiGatewayV2RouterConfig>.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 : RouterBase<ApiGatewayV2RouterConfig>
Examples
ApiGatewayV2Router router = ApiGatewayV2Router
    .CreateBuilder()
    .AddJsonErrorDetails()
    .AddDefaultValueParsers()
    .AddHandler("GET", "/health/", (context, _) => HttpResponseMessage.Json(new { status = "ok" }))
    .CreateRouter();

Methods

CreateBuilder()

Creates a strongly typed builder for ApiGatewayV2Router.

Declaration
public static RouterBuilder<ApiGatewayV2Router, ApiGatewayV2RouterConfig> CreateBuilder()
Returns
Type Description
RouterBuilder<ApiGatewayV2Router, ApiGatewayV2RouterConfig>

A builder that can register handlers, value parsers, and router configuration.

Examples
RouterBuilder<ApiGatewayV2Router, ApiGatewayV2RouterConfig> builder = ApiGatewayV2Router.CreateBuilder();

Route(APIGatewayHttpApiV2ProxyRequest, IServiceProvider, ILambdaContext)

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, ILambdaContext context)
Parameters
Type Name Description
APIGatewayHttpApiV2ProxyRequest request

The API Gateway v2 request event.

IServiceProvider services

The service provider exposed to handlers through Services.

ILambdaContext context

The Lambda invocation context used to derive the cancellation deadline from Amazon.Lambda.Core.ILambdaContext.RemainingTime.

Returns
Type Description
Task<APIGatewayHttpApiV2ProxyResponse>

The API Gateway v2 proxy response generated by NanoRoute.

Examples
APIGatewayHttpApiV2ProxyResponse response = await router.Route(request, services, context);
Exceptions
Type Condition
ArgumentNullException

Thrown when request, services, or context is null.

InvalidOperationException

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