Nullify ServerPortProvider

This commit is contained in:
Jordan Dominion
2023-11-23 18:56:26 -05:00
parent 45a8371acf
commit 34f47edbab
@@ -7,8 +7,6 @@ using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Configuration;
#nullable disable
namespace Tgstation.Server.Host.Core
{
/// <inheritdoc />
@@ -36,18 +34,17 @@ namespace Tgstation.Server.Host.Core
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
ArgumentNullException.ThrowIfNull(configuration);
var usingDefaultPort = generalConfiguration.ApiPort == default;
if (!usingDefaultPort)
return;
var httpEndpoint = configuration
.GetSection("Kestrel")
.GetSection("EndPoints")
.GetSection("Http")
.GetSection("Url")
.Value;
if (generalConfiguration.ApiPort == default && httpEndpoint == null)
throw new InvalidOperationException("Missing required configuration option General:ApiPort!");
if (generalConfiguration.ApiPort != default)
return;
.Value
?? throw new InvalidOperationException("Missing required configuration option General:ApiPort!");
logger.LogWarning("The \"Kestrel\" configuration section is deprecated! Please set your API port using the \"General:ApiPort\" configuration option!");