WebApi: refactor
This commit is contained in:
parent
0c61081921
commit
6af313db1d
@ -13,7 +13,8 @@ global using System.Web;
|
|||||||
|
|
||||||
global using ASC.Api.Collections;
|
global using ASC.Api.Collections;
|
||||||
global using ASC.Api.Core;
|
global using ASC.Api.Core;
|
||||||
global using ASC.Api.Core.Convention;
|
global using ASC.Api.Core.Convention;
|
||||||
|
global using ASC.Api.Core.Extensions;
|
||||||
global using ASC.Api.Settings;
|
global using ASC.Api.Settings;
|
||||||
global using ASC.Api.Utils;
|
global using ASC.Api.Utils;
|
||||||
global using ASC.AuditTrail;
|
global using ASC.AuditTrail;
|
||||||
|
@ -10,51 +10,9 @@ builder.Host.UseWindowsService();
|
|||||||
builder.Host.UseSystemd();
|
builder.Host.UseSystemd();
|
||||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||||
|
|
||||||
builder.WebHost.ConfigureKestrel((hostingContext, serverOptions) =>
|
builder.WebHost.ConfigureDefaultKestrel();
|
||||||
{
|
|
||||||
var kestrelConfig = hostingContext.Configuration.GetSection("Kestrel");
|
|
||||||
|
|
||||||
if (!kestrelConfig.Exists()) return;
|
builder.Host.ConfigureDefaultAppConfiguration(args);
|
||||||
|
|
||||||
var unixSocket = kestrelConfig.GetValue<string>("ListenUnixSocket");
|
|
||||||
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(unixSocket))
|
|
||||||
{
|
|
||||||
unixSocket = string.Format(unixSocket, hostingContext.HostingEnvironment.ApplicationName.Replace("ASC.", "").Replace(".", ""));
|
|
||||||
|
|
||||||
serverOptions.ListenUnixSocket(unixSocket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Host.ConfigureAppConfiguration((hostContext, config) =>
|
|
||||||
{
|
|
||||||
var buided = config.Build();
|
|
||||||
var path = buided["pathToConf"];
|
|
||||||
if (!Path.IsPathRooted(path))
|
|
||||||
{
|
|
||||||
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
|
|
||||||
}
|
|
||||||
|
|
||||||
config.SetBasePath(path);
|
|
||||||
config
|
|
||||||
.AddJsonFile("appsettings.json")
|
|
||||||
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", true)
|
|
||||||
.AddJsonFile("storage.json")
|
|
||||||
.AddJsonFile("kafka.json")
|
|
||||||
.AddJsonFile($"kafka.{hostContext.HostingEnvironment.EnvironmentName}.json", true)
|
|
||||||
.AddJsonFile("redis.json")
|
|
||||||
.AddJsonFile($"redis.{hostContext.HostingEnvironment.EnvironmentName}.json", true)
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.AddCommandLine(args)
|
|
||||||
.AddInMemoryCollection(new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"pathToConf", path }
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Host.ConfigureNLogLogging();
|
builder.Host.ConfigureNLogLogging();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user