| | | 1 | | /******************************************************************************** |
| | | 2 | | * ApiGatewayV2RouterConfig.cs * |
| | | 3 | | * * |
| | | 4 | | * Author: Denes Solti * |
| | | 5 | | ********************************************************************************/ |
| | | 6 | | namespace NanoRoute.AwsLambda |
| | | 7 | | { |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Configuration settings shared by the AWS Lambda router adapters. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <example> |
| | | 14 | | /// <code> |
| | | 15 | | /// ApiGatewayV2Router router = builder.CreateRouter(config => |
| | | 16 | | /// { |
| | | 17 | | /// config.LambdaTimeoutBuffer = TimeSpan.FromSeconds(2); |
| | | 18 | | /// }); |
| | | 19 | | /// </code> |
| | | 20 | | /// </example> |
| | | 21 | | public sealed class ApiGatewayV2RouterConfig : RouterConfig |
| | | 22 | | { |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets or sets the amount of time reserved before the Lambda invocation timeout is reached. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <exception cref="ArgumentOutOfRangeException">Thrown when the assigned value is negative.</exception> |
| | | 27 | | /// <example> |
| | | 28 | | /// <code> |
| | | 29 | | /// ApiGatewayV2Router router = builder.CreateRouter(config => |
| | | 30 | | /// { |
| | | 31 | | /// config.LambdaTimeoutBuffer = TimeSpan.FromSeconds(2); |
| | | 32 | | /// }); |
| | | 33 | | /// </code> |
| | | 34 | | /// </example> |
| | | 35 | | public TimeSpan LambdaTimeoutBuffer |
| | | 36 | | { |
| | | 37 | | get; |
| | | 38 | | set |
| | 1 | 39 | | { |
| | 1 | 40 | | ArgumentOutOfRangeException.ThrowIfLessThan(value, TimeSpan.Zero); |
| | 1 | 41 | | field = value; |
| | 1 | 42 | | } |
| | 1 | 43 | | } = TimeSpan.FromSeconds(1); |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets or sets the URI scheme used when mapping AWS HTTP API and Lambda Function URL events to |
| | | 47 | | /// <see cref="System.Net.Http.HttpRequestMessage.RequestUri"/>. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <remarks> |
| | | 50 | | /// The default is <c>https</c>. |
| | | 51 | | /// </remarks> |
| | | 52 | | /// <exception cref="ArgumentNullException">Thrown when the assigned value is <see langword="null"/>.</exception |
| | | 53 | | /// <example> |
| | | 54 | | /// <code> |
| | | 55 | | /// ApiGatewayV2Router router = builder.CreateRouter(config => |
| | | 56 | | /// { |
| | | 57 | | /// config.RequestScheme = "https"; |
| | | 58 | | /// }); |
| | | 59 | | /// </code> |
| | | 60 | | /// </example> |
| | | 61 | | public string RequestScheme |
| | | 62 | | { |
| | | 63 | | get; |
| | | 64 | | set |
| | 1 | 65 | | { |
| | 1 | 66 | | ArgumentNullException.ThrowIfNull(value); |
| | 1 | 67 | | field = value; |
| | 1 | 68 | | } |
| | 1 | 69 | | } = "https"; |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Gets or sets the host, optionally including a port, used when mapping AWS HTTP API and Lambda Function URL |
| | | 73 | | /// events to <see cref="System.Net.Http.HttpRequestMessage.RequestUri"/>. |
| | | 74 | | /// </summary> |
| | | 75 | | /// <remarks> |
| | | 76 | | /// When this value is <see langword="null"/>, the adapter uses <c>requestContext.domainName</c> from the AWS ev |
| | | 77 | | /// Set this value when your application needs a canonical public host that differs from the event domain name. |
| | | 78 | | /// </remarks> |
| | | 79 | | /// <example> |
| | | 80 | | /// <code> |
| | | 81 | | /// ApiGatewayV2Router router = builder.CreateRouter(config => |
| | | 82 | | /// { |
| | | 83 | | /// config.RequestDomain = "api.example.com"; |
| | | 84 | | /// }); |
| | | 85 | | /// </code> |
| | | 86 | | /// </example> |
| | | 87 | | public string? RequestDomain { get; set; } |
| | | 88 | | } |
| | | 89 | | } |