- pass endpoint to startup via configuration and command line

pull/26/head
Simon Gockner 6 years ago
parent a4b6f69786
commit b76d95e08d
  1. 2
      GBase.Server/GBaseServerSettings.cs
  2. 5
      GBase.Server/Program.cs
  3. 10
      GBase.Server/Startup.cs

@ -14,6 +14,8 @@ namespace GBase.Server
{
public class GBaseServerSettings : IGBaseServerSettings
{
public const string ENDPOINT_STARTUP_CONFIGURATION_PREFIX = "--endpoint";
private const string PROTOCOL_ARGUMENT_PREFIX = "-pr";
private const string IP_ADDRESS_ARGUMENT_PREFIX = "-ip";
private const string PORT_ARGUMENT_PREFIX = "-p";

@ -9,6 +9,7 @@ using GBase.Logging.Interfaces;
using GBase.Server.Interfaces;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace GBase.Server
{
@ -44,6 +45,10 @@ namespace GBase.Server
WebHost.CreateDefaultBuilder()
.UseKestrel(options => { options.Listen(serverSettings.IpAddress, serverSettings.Port); })
.UseUrls($"{serverSettings.Protocol.GetProtocolString()}{serverSettings.IpAddress}:{serverSettings.Port}")
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddCommandLine(new[] {GBaseServerSettings.ENDPOINT_STARTUP_CONFIGURATION_PREFIX, serverSettings.Endpoint});
})
.UseStartup<Startup>();
}
}

@ -7,12 +7,20 @@ using CoreWCF.Configuration;
using GBase.Server.Interfaces;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace GBase.Server
{
public class Startup
{
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceModelServices();
@ -24,7 +32,7 @@ namespace GBase.Server
{
//TODO: Add needed service once it is implemented
//builder.AddService<>();
//builder.AddServiceEndpoint<>(new BasicHttpBinding(), $"/{IGBaseServerSettings.Endpoint}");
//builder.AddServiceEndpoint<>(new BasicHttpBinding(), _configuration[GBaseServerSettings.ENDPOINT_STARTUP_CONFIGURATION_PREFIX]);
});
}
}

Loading…
Cancel
Save