in src/Aspire.Hosting.AWS/Lambda/APIGatewayExtensions.cs [28:55]
public static IResourceBuilder<APIGatewayEmulatorResource> AddAWSAPIGatewayEmulator(this IDistributedApplicationBuilder builder, string name, APIGatewayType apiGatewayType, APIGatewayEmulatorOptions? options = null)
{
options ??= new APIGatewayEmulatorOptions();
var apiGatewayEmulator = builder.AddResource(new APIGatewayEmulatorResource(name, apiGatewayType)).ExcludeFromManifest();
apiGatewayEmulator.WithArgs(context =>
{
apiGatewayEmulator.Resource.AddCommandLineArguments(context.Args);
});
var annotation = new EndpointAnnotation(
protocol: ProtocolType.Tcp,
uriScheme: "http",
port: options.Port);
apiGatewayEmulator.WithAnnotation(annotation);
var endpointReference = new EndpointReference(apiGatewayEmulator.Resource, annotation);
apiGatewayEmulator.WithAnnotation(new EnvironmentCallbackAnnotation(context =>
{
context.EnvironmentVariables[Constants.IsAspireHostedEnvVariable] = "true";
context.EnvironmentVariables["API_GATEWAY_EMULATOR_PORT"] = endpointReference.Property(EndpointProperty.TargetPort);
}));
apiGatewayEmulator.WithAnnotation(new APIGatewayEmulatorAnnotation(apiGatewayType));
return apiGatewayEmulator;
}