diff --git a/Tools/LambdaTestTool/tests/LambdaFunctions/AspNetCoreAPIExample/LocalEntryPoint.cs b/Tools/LambdaTestTool/tests/LambdaFunctions/AspNetCoreAPIExample/LocalEntryPoint.cs index dd8c63772..6612690e0 100644 --- a/Tools/LambdaTestTool/tests/LambdaFunctions/AspNetCoreAPIExample/LocalEntryPoint.cs +++ b/Tools/LambdaTestTool/tests/LambdaFunctions/AspNetCoreAPIExample/LocalEntryPoint.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace AspNetCoreAPIExample @@ -14,14 +16,39 @@ public class LocalEntryPoint { public static void Main(string[] args) { - CreateHostBuilder(args).Build().Run(); + CreateHostBuilder(args).Run(); } - public static WebApplicationBuilder CreateHostBuilder(string[] args) + public static WebApplication CreateHostBuilder(string[] args) { var builder = WebApplication.CreateBuilder(args); - builder.WebHost.UseStartup(); - return builder; + + builder.Services.AddScoped(); + builder.Services.AddControllers(); + + var app = builder.Build(); + + if (app.Environment.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + endpoints.MapGet("/", async context => + { + await context.Response.WriteAsync("Welcome to running ASP.NET Core on AWS Lambda"); + }); + }); + + return app; } } }