aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-04-24 10:57:28 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-04-24 10:57:28 -0500
commit5a30bbdee5779efb117f1de421397bd09621e1f7 (patch)
tree726637479a094de78091884d2a2010849304dd41 /src/slskd/Program.cs
parent9ae756c433ab05d5c1531a347ac4928ee99f1188 (diff)
downloadslskd-5a30bbdee5779efb117f1de421397bd09621e1f7.tar.gz
convert to extensions
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 1e51cc5b..6e855ecf 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -372,14 +372,13 @@ namespace slskd
}
});
- var services = builder.Services;
-
- ConfigureAspDotNetServices(services);
- ConfigureDependencyInjectionContainer(services);
+ builder.Services
+ .ConfigureAspDotNetServices()
+ .ConfigureDependencyInjectionContainer();
var app = builder.Build();
- ConfigureAspDotNetPipeline(app);
+ app.ConfigureAspDotNetPipeline();
if (OptionsAtStartup.NoStart)
{
@@ -399,7 +398,7 @@ namespace slskd
}
}
- private static void ConfigureDependencyInjectionContainer(IServiceCollection services)
+ private static IServiceCollection ConfigureDependencyInjectionContainer(this IServiceCollection services)
{
// add the instance of OptionsAtStartup to DI as they were at startup. use when Options might change, but
// the values at startup are to be used (generally anything marked RequiresRestart).
@@ -471,9 +470,11 @@ namespace slskd
});
services.InitializeDbContext<SearchDbContext>();
+
+ return services;
}
- private static void ConfigureAspDotNetServices(IServiceCollection services)
+ private static IServiceCollection ConfigureAspDotNetServices(this IServiceCollection services)
{
services.AddCors(options => options.AddPolicy("AllowAll", builder => builder
.AllowAnyHeader()
@@ -583,9 +584,11 @@ namespace slskd
{
services.AddSystemMetrics();
}
+
+ return services;
}
- private static void ConfigureAspDotNetPipeline(WebApplication app)
+ private static WebApplication ConfigureAspDotNetPipeline(this WebApplication app)
{
app.UseExceptionHandler(a => a.Run(async context =>
{
@@ -703,6 +706,8 @@ namespace slskd
{
app.UseFileServer(fileServerOptions);
}
+
+ return app;
}
private static void ConfigureGlobalLogger()