From 5e030cf9456664447109d75f926698e95f3016aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:18:04 +0000 Subject: [PATCH 1/5] Initial plan From 374fcfa9bc0b0c2d99b2d02de88e89d9621e0889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:20:22 +0000 Subject: [PATCH 2/5] Refactor Startup.Configure into helpers Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- TransactionProcessorACL/Startup.cs | 65 +++++++++++++++++++----------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/TransactionProcessorACL/Startup.cs b/TransactionProcessorACL/Startup.cs index 8ddf198..79772c4 100644 --- a/TransactionProcessorACL/Startup.cs +++ b/TransactionProcessorACL/Startup.cs @@ -16,6 +16,7 @@ namespace TransactionProcessorACL using MediatR; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Routing; using Shared.Extensions; using Shared.General; using Shared.Logger; @@ -66,48 +67,64 @@ public void ConfigureContainer(ServiceRegistry services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + Startup.UseDevelopmentExceptionPage(app, env); + Startup.InitialiseLogger(loggerFactory); + Startup.ConfigureMiddleware(app); + Startup.ConfigureEndpoints(app); + app.UseSwagger(); + app.UseSwaggerUI(); + } + + private static void UseDevelopmentExceptionPage(IApplicationBuilder app, + IWebHostEnvironment env) { if (env.IsDevelopment()) - { + { app.UseDeveloperExceptionPage(); } - + } + + private static void InitialiseLogger(ILoggerFactory loggerFactory) + { ILogger logger = loggerFactory.CreateLogger("TransactionProcessor"); Logger.Initialise(logger); - Startup.Configuration.LogConfiguration(Logger.LogWarning); + } + + private static void ConfigureMiddleware(IApplicationBuilder app) + { app.UseMiddleware(); app.AddRequestResponseLogging(); app.AddExceptionHandler(); app.UseMiddleware(); - app.UseRouting(); - app.UseAuthentication(); app.UseAuthorization(); + } - app.UseEndpoints(endpoints => - { - endpoints.MapMerchantEndpoints(); - endpoints.MapTransactionEndpoints(); - endpoints.MapVoucherEndpoints(); - - endpoints.MapHealthChecks("health", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = Shared.HealthChecks.HealthCheckMiddleware.WriteResponse - }); - endpoints.MapHealthChecks("healthui", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - }); + private static void ConfigureEndpoints(IApplicationBuilder app) + { + app.UseEndpoints(Startup.MapEndpoints); + } - app.UseSwagger(); + private static void MapEndpoints(IEndpointRouteBuilder endpoints) + { + endpoints.MapMerchantEndpoints(); + endpoints.MapTransactionEndpoints(); + endpoints.MapVoucherEndpoints(); + endpoints.MapHealthChecks("health", Startup.CreateHealthCheckOptions(Shared.HealthChecks.HealthCheckMiddleware.WriteResponse)); + endpoints.MapHealthChecks("healthui", Startup.CreateHealthCheckOptions(UIResponseWriter.WriteHealthCheckUIResponse)); + } - app.UseSwaggerUI(); + private static HealthCheckOptions CreateHealthCheckOptions(Func responseWriter) + { + return new HealthCheckOptions + { + Predicate = _ => true, + ResponseWriter = responseWriter + }; } } } From ad706a61094c66def14c233130f709ab261dd1de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:25:05 +0000 Subject: [PATCH 3/5] Polish Startup.Configure helper refactor Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- TransactionProcessorACL/Startup.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/TransactionProcessorACL/Startup.cs b/TransactionProcessorACL/Startup.cs index 79772c4..53bf623 100644 --- a/TransactionProcessorACL/Startup.cs +++ b/TransactionProcessorACL/Startup.cs @@ -68,12 +68,11 @@ public void ConfigureContainer(ServiceRegistry services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { - Startup.UseDevelopmentExceptionPage(app, env); - Startup.InitialiseLogger(loggerFactory); - Startup.ConfigureMiddleware(app); - Startup.ConfigureEndpoints(app); - app.UseSwagger(); - app.UseSwaggerUI(); + UseDevelopmentExceptionPage(app, env); + InitializeLogger(loggerFactory); + ConfigureMiddleware(app); + ConfigureEndpoints(app); + ConfigureSwagger(app); } private static void UseDevelopmentExceptionPage(IApplicationBuilder app, @@ -85,7 +84,7 @@ private static void UseDevelopmentExceptionPage(IApplicationBuilder app, } } - private static void InitialiseLogger(ILoggerFactory loggerFactory) + private static void InitializeLogger(ILoggerFactory loggerFactory) { ILogger logger = loggerFactory.CreateLogger("TransactionProcessor"); @@ -106,7 +105,13 @@ private static void ConfigureMiddleware(IApplicationBuilder app) private static void ConfigureEndpoints(IApplicationBuilder app) { - app.UseEndpoints(Startup.MapEndpoints); + app.UseEndpoints(MapEndpoints); + } + + private static void ConfigureSwagger(IApplicationBuilder app) + { + app.UseSwagger(); + app.UseSwaggerUI(); } private static void MapEndpoints(IEndpointRouteBuilder endpoints) @@ -114,8 +119,8 @@ private static void MapEndpoints(IEndpointRouteBuilder endpoints) endpoints.MapMerchantEndpoints(); endpoints.MapTransactionEndpoints(); endpoints.MapVoucherEndpoints(); - endpoints.MapHealthChecks("health", Startup.CreateHealthCheckOptions(Shared.HealthChecks.HealthCheckMiddleware.WriteResponse)); - endpoints.MapHealthChecks("healthui", Startup.CreateHealthCheckOptions(UIResponseWriter.WriteHealthCheckUIResponse)); + endpoints.MapHealthChecks("health", CreateHealthCheckOptions(Shared.HealthChecks.HealthCheckMiddleware.WriteResponse)); + endpoints.MapHealthChecks("healthui", CreateHealthCheckOptions(UIResponseWriter.WriteHealthCheckUIResponse)); } private static HealthCheckOptions CreateHealthCheckOptions(Func responseWriter) From 230ef59cdbe25c77208244bcfbcf12766f04aae5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:57:26 +0000 Subject: [PATCH 4/5] Fix Startup health check helper build Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- TransactionProcessorACL/Startup.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TransactionProcessorACL/Startup.cs b/TransactionProcessorACL/Startup.cs index 53bf623..b6447cf 100644 --- a/TransactionProcessorACL/Startup.cs +++ b/TransactionProcessorACL/Startup.cs @@ -17,15 +17,18 @@ namespace TransactionProcessorACL using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; + using Microsoft.Extensions.Diagnostics.HealthChecks; using Shared.Extensions; using Shared.General; using Shared.Logger; using Shared.Middleware; + using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Text; using System.Text.Json; using System.Threading; + using System.Threading.Tasks; using TransactionProcessorACL.Middleware; using ILogger = Microsoft.Extensions.Logging.ILogger; From ffce348bc8153e46ab578862690fdece0dd5ca60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 20:07:29 +0000 Subject: [PATCH 5/5] Fix Startup health check delegate signature Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- TransactionProcessorACL/Startup.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TransactionProcessorACL/Startup.cs b/TransactionProcessorACL/Startup.cs index b6447cf..d775861 100644 --- a/TransactionProcessorACL/Startup.cs +++ b/TransactionProcessorACL/Startup.cs @@ -27,7 +27,6 @@ namespace TransactionProcessorACL using System.IO; using System.Text; using System.Text.Json; - using System.Threading; using System.Threading.Tasks; using TransactionProcessorACL.Middleware; using ILogger = Microsoft.Extensions.Logging.ILogger; @@ -126,7 +125,7 @@ private static void MapEndpoints(IEndpointRouteBuilder endpoints) endpoints.MapHealthChecks("healthui", CreateHealthCheckOptions(UIResponseWriter.WriteHealthCheckUIResponse)); } - private static HealthCheckOptions CreateHealthCheckOptions(Func responseWriter) + private static HealthCheckOptions CreateHealthCheckOptions(Func responseWriter) { return new HealthCheckOptions {