Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CallbackHander.Testing/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static TokenResponse TokenResponse()
["SecurityConfiguration:Authority"] = "https://127.0.0.1",
["AppSettings:EstateManagementApi"] = "http://127.0.0.1",
["AppSettings:SecurityService"] = "http://127.0.0.1",
["AppSettings:TransactionProcessorApi"] = "http://127.0.0.1",
["AppSettings:ContractProductFeeCacheExpiryInHours"] = "",
["AppSettings:ContractProductFeeCacheEnabled"] = "",
["ConnectionStrings:HealthCheck"] = "HealthCheck",
Expand Down
1 change: 1 addition & 0 deletions CallbackHandler.Tests/BootstrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private IConfigurationRoot SetupMemoryConfiguration()
configuration.Add("AppSettings:SecurityService", "http://127.0.0.1");
configuration.Add("AppSettings:MessagingServiceApi", "http://127.0.0.1");
configuration.Add("AppSettings:DatabaseEngine", "SqlServer");
configuration.Add("AppSettings:TransactionProcessorApi","http://127.0.0.1");

builder.AddInMemoryCollection(configuration);

Expand Down
64 changes: 24 additions & 40 deletions CallbackHandler/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using KurrentDB.Client;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi;
using Shared.Extensions;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace CallbackHandler.Bootstrapper;

Expand Down Expand Up @@ -32,40 +34,10 @@ public MiddlewareRegistry()
String connectionString = Startup.Configuration.GetValue<String>("EventStoreSettings:ConnectionString");
KurrentDBClientSettings eventStoreSettings = KurrentDBClientSettings.Create(connectionString);

this.AddHealthChecks().AddEventStore(eventStoreSettings,
userCredentials: eventStoreSettings.DefaultCredentials,
name: "Eventstore",
failureStatus: HealthStatus.Unhealthy,
tags: new[] { "db", "eventstore" });
this.AddHealthChecks().AddEventStore(eventStoreSettings, userCredentials: eventStoreSettings.DefaultCredentials,
name: "Eventstore", failureStatus: HealthStatus.Unhealthy, tags: new[] { "db", "eventstore" });

this.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Callback Handler API",
Version = "1.0",
Description = "A REST Api to handle callback requests from external parties API's.",
Contact = new OpenApiContact
{
Name = "Stuart Ferguson",
Email = "golfhandicapping@btinternet.com"
}
});
// add a custom operation filter which sets default values
c.OperationFilter<SwaggerDefaultValues>();
c.ExampleFilters();

//Locate the XML files being generated by ASP.NET...
DirectoryInfo directory = new(AppContext.BaseDirectory);
FileInfo[] xmlFiles = directory.GetFiles("*.xml");

//... and tell Swagger to use those XML comments.
foreach (FileInfo fileInfo in xmlFiles)
{
c.IncludeXmlComments(fileInfo.FullName);
}

});
this.AddSwaggerGen(AddSwaggerAction);
this.AddSwaggerExamples();

this.AddControllers().AddNewtonsoftJson(options =>
Expand All @@ -83,16 +55,28 @@ public MiddlewareRegistry()
bool logRequests = ConfigurationReader.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogRequests", true);
bool logResponses = ConfigurationReader.GetValueOrDefault<Boolean>("MiddlewareLogging", "LogResponses", true);
LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault<LogLevel>("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning);

this.AddSingleton(new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses));

RequestResponseMiddlewareLoggingConfig config =
new(middlewareLogLevel, logRequests, logResponses);

this.AddSingleton(config);

this.ConfigureHttpJsonOptions(options =>
{
this.ConfigureHttpJsonOptions(options => {
options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy();
options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer
});
}

private void AddSwaggerAction(SwaggerGenOptions c) {
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Callback Handler API", Version = "1.0", Description = "A REST Api to handle callback requests from external parties API's.", Contact = new OpenApiContact { Name = "Stuart Ferguson", Email = "golfhandicapping@btinternet.com" } });
// add a custom operation filter which sets default values
c.OperationFilter<SwaggerDefaultValues>();
c.ExampleFilters();

//Locate the XML files being generated by ASP.NET...
DirectoryInfo directory = new(AppContext.BaseDirectory);
FileInfo[] xmlFiles = directory.GetFiles("*.xml");

//... and tell Swagger to use those XML comments.
foreach (FileInfo fileInfo in xmlFiles) {
c.IncludeXmlComments(fileInfo.FullName);
}
}
}
Loading