Skip to content

Commit

Permalink
Register /health endpoint on App and API
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Dec 6, 2024
1 parent 7595704 commit 55c9a2c
Show file tree
Hide file tree
Showing 2 changed files with 264 additions and 261 deletions.
103 changes: 53 additions & 50 deletions ConcernsCaseWork/ConcernsCaseWork.API/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
using ConcernsCaseWork.API.Extensions;
using ConcernsCaseWork.API.Middleware;
using ConcernsCaseWork.API.StartupConfiguration;
using ConcernsCaseWork.Middleware;
using Microsoft.AspNetCore.Mvc.ApiExplorer;

namespace ConcernsCaseWork.API
{
/// <summary>
/// THIS STARTUP ISN'T USED WHEN API IS HOSTED THROUGH WEBSITE. It is used when running API tests
/// </summary>
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

public void ConfigureServices(IServiceCollection services)
{
services.AddConcernsApiProject(Configuration);
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
{
app.UseConcernsCaseworkSwagger(provider);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseMiddleware<ExceptionHandlerMiddleware>();
app.UseMiddleware<ApiKeyMiddleware>();
app.UseMiddleware<UrlDecoderMiddleware>();
app.UseMiddleware<CorrelationIdMiddleware>();
app.UseMiddleware<UserContextReceiverMiddleware>();

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseConcernsCaseworkEndpoints();
}
}
}
using ConcernsCaseWork.API.Extensions;
using ConcernsCaseWork.API.Middleware;
using ConcernsCaseWork.API.StartupConfiguration;
using ConcernsCaseWork.Middleware;
using Microsoft.AspNetCore.Mvc.ApiExplorer;

namespace ConcernsCaseWork.API
{
/// <summary>
/// THIS STARTUP ISN'T USED WHEN API IS HOSTED THROUGH WEBSITE. It is used when running API tests
/// </summary>
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

public void ConfigureServices(IServiceCollection services)
{
services.AddConcernsApiProject(Configuration);
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
{
app.UseConcernsCaseworkSwagger(provider);

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseMiddleware<ExceptionHandlerMiddleware>();
app.UseMiddleware<ApiKeyMiddleware>();
app.UseMiddleware<UrlDecoderMiddleware>();
app.UseMiddleware<CorrelationIdMiddleware>();
app.UseMiddleware<UserContextReceiverMiddleware>();

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseConcernsCaseworkEndpoints();

// Add Health Checks
app.UseHealthChecks("/health");
}
}
}
Loading

0 comments on commit 55c9a2c

Please sign in to comment.