diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs index 67f467101..aa4b08564 100644 --- a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs @@ -22,7 +22,7 @@ namespace Amazon.Lambda.AspNetCoreServer { /// - /// ApiGatewayFunction is the base class that is implemented in a ASP.NET Core Web API. The derived class implements + /// ApiGatewayProxyFunction is the base class that is implemented in a ASP.NET Core Web API. The derived class implements /// the Init method similar to Main function in the ASP.NET Core. The function handler for the Lambda function will point /// to this base class FunctionHandlerAsync method. /// diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction{TStartup}.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction{TStartup}.cs new file mode 100644 index 000000000..7758104be --- /dev/null +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction{TStartup}.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Hosting; + +namespace Amazon.Lambda.AspNetCoreServer +{ + /// + /// ApiGatewayProxyFunction is the base class that is implemented in a ASP.NET Core Web API. The derived class implements + /// the Init method similar to Main function in the ASP.NET Core and provides typed Startup. The function handler for + /// the Lambda function will point to this base class FunctionHandlerAsync method. + /// + /// The type containing the startup methods for the application. + public abstract class APIGatewayProxyFunction : APIGatewayProxyFunction where TStartup : class + { + /// + protected override IWebHostBuilder CreateWebHostBuilder() => + base.CreateWebHostBuilder().UseStartup(); + + /// + protected override void Init(IWebHostBuilder builder) + { + } + } +} diff --git a/Libraries/test/TestWebApp/Controllers/BinaryContentController.cs b/Libraries/test/TestWebApp/Controllers/BinaryContentController.cs index b257d72f5..196a56c47 100644 --- a/Libraries/test/TestWebApp/Controllers/BinaryContentController.cs +++ b/Libraries/test/TestWebApp/Controllers/BinaryContentController.cs @@ -1,5 +1,5 @@ -using System.IO; using Microsoft.AspNetCore.Mvc; +using static System.Net.Mime.MediaTypeNames; namespace TestWebApp.Controllers { @@ -14,7 +14,7 @@ public IActionResult Get([FromQuery] string firstName, [FromQuery] string lastNa for (int i = 0; i < bytes.Length; i++) bytes[i] = (byte)i; - return base.File(bytes, LambdaFunction.BinaryContentType); + return base.File(bytes, Application.Octet); } } -} \ No newline at end of file +} diff --git a/Libraries/test/TestWebApp/LambdaFunction.cs b/Libraries/test/TestWebApp/LambdaFunction.cs index 898840424..fc3c3410a 100644 --- a/Libraries/test/TestWebApp/LambdaFunction.cs +++ b/Libraries/test/TestWebApp/LambdaFunction.cs @@ -1,20 +1,8 @@ -using System.IO; - -using Amazon.Lambda.AspNetCoreServer; -using Microsoft.AspNetCore.Hosting; +using Amazon.Lambda.AspNetCoreServer; namespace TestWebApp { - public class LambdaFunction : APIGatewayProxyFunction + public class LambdaFunction : APIGatewayProxyFunction { - public const string BinaryContentType = "application/octet-stream"; - - protected override void Init(IWebHostBuilder builder) - { - builder - .UseApiGateway() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseStartup(); - } } }