Skip to content

Commit 5f8f060

Browse files
committed
Adds Default Implementation of Init for Typed Startup
Because an `IWebHostBuilder` can exit `CreateWebHostBuilder` in a usable state, `Init` may not be necessary to override in a client's entry point.
1 parent 45c89ba commit 5f8f060

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction{TStartup}.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ public abstract class APIGatewayProxyFunction<TStartup> : APIGatewayProxyFunctio
1313
/// <inheritdoc/>
1414
protected override IWebHostBuilder CreateWebHostBuilder() =>
1515
base.CreateWebHostBuilder().UseStartup<TStartup>();
16+
17+
/// <inheritdoc/>
18+
protected override void Init(IWebHostBuilder builder)
19+
{
20+
}
1621
}
1722
}

Libraries/test/TestWebApp/Controllers/BinaryContentController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.IO;
21
using Microsoft.AspNetCore.Mvc;
2+
using static System.Net.Mime.MediaTypeNames;
33

44
namespace TestWebApp.Controllers
55
{
@@ -14,7 +14,7 @@ public IActionResult Get([FromQuery] string firstName, [FromQuery] string lastNa
1414
for (int i = 0; i < bytes.Length; i++)
1515
bytes[i] = (byte)i;
1616

17-
return base.File(bytes, LambdaFunction.BinaryContentType);
17+
return base.File(bytes, Application.Octet);
1818
}
1919
}
20-
}
20+
}
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
using System.IO;
2-
3-
using Amazon.Lambda.AspNetCoreServer;
4-
using Microsoft.AspNetCore.Hosting;
1+
using Amazon.Lambda.AspNetCoreServer;
52

63
namespace TestWebApp
74
{
85
public class LambdaFunction : APIGatewayProxyFunction<Startup>
96
{
10-
public const string BinaryContentType = "application/octet-stream";
11-
12-
protected override void Init(IWebHostBuilder builder)
13-
{
14-
builder
15-
.UseApiGateway()
16-
.UseContentRoot(Directory.GetCurrentDirectory());
17-
}
187
}
198
}

0 commit comments

Comments
 (0)