Skip to content

Commit 1bf1a49

Browse files
authored
Update Program.cs (#2852)
* Update Program.cs * Update BervProject.WebApi.Boilerplate.csproj * Update Program.cs * Update Program.cs * Update HealthCheckTest.cs
1 parent c336c72 commit 1bf1a49

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

BervProject.WebApi.Boilerplate/BervProject.WebApi.Boilerplate.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
4646
</ItemGroup>
4747

48+
<ItemGroup>
49+
<ProjectReference Include="..\BervProject.WebApi.Boilerplate.ServiceDefaults\BervProject.WebApi.Boilerplate.ServiceDefaults.csproj" />
50+
</ItemGroup>
4851
<ItemGroup>
4952
<Content Update="nlog.config" CopyToOutputDirectory="PreserveNewest" />
5053
</ItemGroup>

BervProject.WebApi.Boilerplate/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using NLog.Web;
2020

2121
var builder = WebApplication.CreateBuilder(args);
22+
builder.AddServiceDefaults();
2223
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
2324
builder.Logging.ClearProviders();
2425
builder.Logging.SetMinimumLevel(LogLevel.Trace);
@@ -54,7 +55,6 @@
5455
});
5556
builder.Services.AddDbContext<BoilerplateDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("BoilerplateConnectionString")));
5657

57-
builder.Services.AddHealthChecks();
5858
builder.Services.AddControllers();
5959
builder.Services.AddApiVersioning();
6060
builder.Services.AddSwaggerGen(options =>
@@ -101,8 +101,6 @@
101101

102102
app.UseAuthorization();
103103

104-
app.MapHealthChecks("/healthz");
105-
106104
app.UseSwagger(c =>
107105
{
108106
c.RouteTemplate = "api/docs/{documentName}/swagger.json";
@@ -114,6 +112,8 @@
114112
c.RoutePrefix = "api/docs";
115113
});
116114

115+
app.MapDefaultEndpoints();
116+
117117
app.MapControllers();
118118
app.MapHangfireDashboard();
119119

BervProject.WebApi.Integration.Test/HealthCheckTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public HealthCheckTest(WebAppFixture webAppFixtures)
1515
public async Task SuccessCheck()
1616
{
1717
var client = _applicationFactory.CreateClient();
18-
var response = await client.GetAsync("/healthz");
18+
var response = await client.GetAsync("/health");
1919
Assert.True(response.IsSuccessStatusCode);
2020
var stringResponse = await response.Content.ReadAsStringAsync();
2121
Assert.Equal("Healthy", stringResponse);

0 commit comments

Comments
 (0)