diff --git a/Finch/ApplicationBuilderExtensions.cs b/Finch/ApplicationBuilderExtensions.cs index d307b302..ccb114ca 100644 --- a/Finch/ApplicationBuilderExtensions.cs +++ b/Finch/ApplicationBuilderExtensions.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; namespace Finch; @@ -7,6 +8,7 @@ public static class ApplicationBuilderExtensions public static IApplicationBuilder UseFinch(this IApplicationBuilder app) { app.UseMiddleware(); + app.UseResponseCaching(); app.UseOutputCache(); if (app is WebApplication webApplication) @@ -15,7 +17,7 @@ public static class ApplicationBuilderExtensions webApplication.MapControllers(); } - FinchBuilder.Modules.Configure(app, null, app.ApplicationServices); + FinchBuilder.Modules.Configure(app, app as IEndpointRouteBuilder, app.ApplicationServices); return app; } } diff --git a/Finch/FinchBuilder.cs b/Finch/FinchBuilder.cs index 64e66bde..ee9c3b27 100644 --- a/Finch/FinchBuilder.cs +++ b/Finch/FinchBuilder.cs @@ -38,6 +38,7 @@ public class FinchBuilder startupOptions.AssemblyDiscoveryRules.Add(new FinchAssemblyDiscoveryRule()); setupAction?.Invoke(startupOptions); + services.AddResponseCaching(); services.AddControllers(); services.AddOutputCache(); mvcBuilder = services.AddRazorPages(); diff --git a/Finch/Logging/FinchLoggingModule.cs b/Finch/Logging/FinchLoggingModule.cs index 4086c802..e03f6dd9 100644 --- a/Finch/Logging/FinchLoggingModule.cs +++ b/Finch/Logging/FinchLoggingModule.cs @@ -15,7 +15,7 @@ public class FinchLoggingModule : FinchModule { // get seq configuration IConfigurationSection seqConfig = configuration.GetSection("Finch:Seq"); - FinchSeqOptions seqOptions = seqConfig.Get(); + FinchSeqOptions seqOptions = seqConfig.Get() ?? new(); // default level builder.SetMinimumLevel(seqOptions.MinimumLevel); @@ -27,7 +27,7 @@ public class FinchLoggingModule : FinchModule } // add optional seq sink - if (seqConfig.Exists()) + if (seqConfig.Exists() && seqOptions.ApiKey.HasValue()) { builder.AddSeq(seqOptions.ServerUrl, seqOptions.ApiKey, seqOptions.Enrichers); } diff --git a/Finch/Mvc/FinchMvcModule.cs b/Finch/Mvc/FinchMvcModule.cs index 8ca9a33e..22a69026 100644 --- a/Finch/Mvc/FinchMvcModule.cs +++ b/Finch/Mvc/FinchMvcModule.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Finch.Mvc; @@ -8,5 +10,12 @@ public class FinchMvcModule : FinchModule public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddRouting(opts => opts.LowercaseUrls = true); + services.AddHealthChecks(); + } + + + public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) + { + routes.MapHealthChecks("/health"); } } \ No newline at end of file