From 1a3c221b4ee4728d3f10a62c6d16a48fabe79bcf Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Mon, 10 Feb 2020 16:02:53 +0100 Subject: [PATCH] - add endpoints for base, table and entry --- .../Communication/ICommunicationSettings.cs | 4 +- GBase.Client/GBaseClientSettings.cs | 15 +++++-- .../Interfaces/IGBaseClientSettings.cs | 4 +- GBase.Server/GBaseServerSettings.cs | 41 +++++++++++++++---- GBase.Server/Program.cs | 7 +++- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/GBase.Api/Communication/ICommunicationSettings.cs b/GBase.Api/Communication/ICommunicationSettings.cs index 184acfb..78db4d8 100644 --- a/GBase.Api/Communication/ICommunicationSettings.cs +++ b/GBase.Api/Communication/ICommunicationSettings.cs @@ -11,6 +11,8 @@ namespace GBase.Api.Communication ServerProtocol Protocol { get; } IPAddress IpAddress { get; } int Port { get; } - string Endpoint { get; } + string GBaseEndpoint { get; } + string GBaseTableEndpoint { get; } + string GBaseEntryEndpoint { get; } } } \ No newline at end of file diff --git a/GBase.Client/GBaseClientSettings.cs b/GBase.Client/GBaseClientSettings.cs index fedddab..c5223c7 100644 --- a/GBase.Client/GBaseClientSettings.cs +++ b/GBase.Client/GBaseClientSettings.cs @@ -10,18 +10,25 @@ namespace GBase.Client { public class GBaseClientSettings : IGBaseClientSettings { - public GBaseClientSettings(ServerProtocol protocol, IPAddress ipAddress, int port, string endpoint) + public GBaseClientSettings(ServerProtocol protocol, IPAddress ipAddress, int port, string gBaseEndpoint, string gBaseTableEndpoint, string gBaseEntryEndpoint) { Protocol = protocol; IpAddress = ipAddress; Port = port; - Endpoint = endpoint; + GBaseEndpoint = gBaseEndpoint; + GBaseTableEndpoint = gBaseTableEndpoint; + GBaseEntryEndpoint = gBaseEntryEndpoint; } public ServerProtocol Protocol { get; } public IPAddress IpAddress { get; } public int Port { get; } - public string Endpoint { get; } - public string ServerProtocolEndpointAddress => @$"{Protocol.GetProtocolString()}{IpAddress}:{Port}{Endpoint}"; + public string GBaseEndpoint { get; } + public string GBaseTableEndpoint { get; } + public string GBaseEntryEndpoint { get; } + + public string ServerProtocolGBaseEndpointAddress => @$"{Protocol.GetProtocolString()}{IpAddress}:{Port}{GBaseEndpoint}"; + public string ServerProtocolGBaseTableEndpointAddress => @$"{Protocol.GetProtocolString()}{IpAddress}:{Port}{GBaseTableEndpoint}"; + public string ServerProtocolGBaseEntryEndpointAddress => @$"{Protocol.GetProtocolString()}{IpAddress}:{Port}{GBaseEntryEndpoint}"; } } \ No newline at end of file diff --git a/GBase.Client/Interfaces/IGBaseClientSettings.cs b/GBase.Client/Interfaces/IGBaseClientSettings.cs index 36111a3..a48bc19 100644 --- a/GBase.Client/Interfaces/IGBaseClientSettings.cs +++ b/GBase.Client/Interfaces/IGBaseClientSettings.cs @@ -8,6 +8,8 @@ namespace GBase.Client.Interfaces { public interface IGBaseClientSettings : ICommunicationSettings { - string ServerProtocolEndpointAddress { get; } + string ServerProtocolGBaseEndpointAddress { get; } + string ServerProtocolGBaseTableEndpointAddress { get; } + string ServerProtocolGBaseEntryEndpointAddress { get; } } } \ No newline at end of file diff --git a/GBase.Server/GBaseServerSettings.cs b/GBase.Server/GBaseServerSettings.cs index 306d9d4..134f3f6 100644 --- a/GBase.Server/GBaseServerSettings.cs +++ b/GBase.Server/GBaseServerSettings.cs @@ -15,12 +15,16 @@ namespace GBase.Server { public class GBaseServerSettings : IGBaseServerSettings { - public const string ENDPOINT_STARTUP_CONFIGURATION_PREFIX = "--endpoint"; + public const string GBASE_ENDPOINT_STARTUP_CONFIGURATION_PREFIX = "--GBaseEndpoint"; + public const string GBASE_TABLE_ENDPOINT_STARTUP_CONFIGURATION_PREFIX = "--GBaseTableEndpoint"; + public const string GBASE_ENTRY_ENDPOINT_STARTUP_CONFIGURATION_PREFIX = "--GBaseEntryEndpoint"; private const string PROTOCOL_ARGUMENT_PREFIX = "-pr"; private const string IP_ADDRESS_ARGUMENT_PREFIX = "-ip"; private const string PORT_ARGUMENT_PREFIX = "-p"; private const string ENDPOINT_ARGUMENT_PREFIX = "-e"; + private const string TABLE_ENDPOINT_ARGUMENT_PREFIX = "-et"; + private const string ENTRY_ENDPOINT_ARGUMENT_PREFIX = "-ee"; private const string LOG_FILE_PATH_ARGUMENT_PREFIX = "-lp"; private const string LOG_FILE_NAME_ARGUMENT_PREFIX = "-ln"; @@ -33,14 +37,19 @@ namespace GBase.Server private bool _protocolInitialized; private bool _ipAddressInitialized; private bool _portInitialized; - private bool _endpointInitialized; + private bool _gBaseEndpointInitialized; + private bool _gBaseTableEndpointInitialized; + private bool _gBaseEntryEndpointInitialized; + private bool _logFilePathInitialized; private bool _logFileNameInitialized; public ServerProtocol Protocol { get; private set; } public IPAddress IpAddress { get; private set; } public int Port { get; private set; } - public string Endpoint { get; private set; } + public string GBaseEndpoint { get; private set; } + public string GBaseTableEndpoint { get; private set; } + public string GBaseEntryEndpoint { get; private set; } public string LogFilePath { get; private set; } public string LogFileName { get; private set; } @@ -78,8 +87,24 @@ namespace GBase.Server index++; await VerifyArgsLength(index, args.Length); - Endpoint = args[index]; - _endpointInitialized = true; + GBaseEndpoint = args[index]; + _gBaseEndpointInitialized = true; + } + else if (args[index] == TABLE_ENDPOINT_ARGUMENT_PREFIX) + { + index++; + await VerifyArgsLength(index, args.Length); + + GBaseTableEndpoint = args[index]; + _gBaseTableEndpointInitialized = true; + } + else if (args[index] == ENTRY_ENDPOINT_ARGUMENT_PREFIX) + { + index++; + await VerifyArgsLength(index, args.Length); + + GBaseEntryEndpoint = args[index]; + _gBaseEntryEndpointInitialized = true; } else if (args[index] == LOG_FILE_PATH_ARGUMENT_PREFIX) { @@ -127,7 +152,7 @@ namespace GBase.Server LogFileName = _defaultLogFileName; //mandatory settings - if (_protocolInitialized && _ipAddressInitialized && _portInitialized && _endpointInitialized) + if (_protocolInitialized && _ipAddressInitialized && _portInitialized && _gBaseEndpointInitialized && _gBaseTableEndpointInitialized && _gBaseEntryEndpointInitialized) return true; await PrintHelp(); @@ -154,7 +179,9 @@ namespace GBase.Server await Log.Write($"{PROTOCOL_ARGUMENT_PREFIX}: The used protocol (e.g 'http' or 'https')"); await Log.Write($"{IP_ADDRESS_ARGUMENT_PREFIX}: The used ip address"); await Log.Write($"{PORT_ARGUMENT_PREFIX}: The used port"); - await Log.Write($"{ENDPOINT_ARGUMENT_PREFIX}: The used endpoint"); + await Log.Write($"{ENDPOINT_ARGUMENT_PREFIX}: The used GBase endpoint"); + await Log.Write($"{TABLE_ENDPOINT_ARGUMENT_PREFIX}: The used GBase table endpoint"); + await Log.Write($"{ENTRY_ENDPOINT_ARGUMENT_PREFIX}: The used GBase entry endpoint"); await Log.Write(""); await Log.Write("Optional Arguments:"); await Log.Write($"{LOG_FILE_PATH_ARGUMENT_PREFIX}: The path to the server log file (default: '{_defaultLogFilePath}')"); diff --git a/GBase.Server/Program.cs b/GBase.Server/Program.cs index 8430e0e..3ef2c07 100644 --- a/GBase.Server/Program.cs +++ b/GBase.Server/Program.cs @@ -48,7 +48,12 @@ namespace GBase.Server .UseUrls($"{serverSettings.Protocol.GetProtocolString()}{serverSettings.IpAddress}:{serverSettings.Port}") .ConfigureAppConfiguration((hostingContext, config) => { - config.AddCommandLine(new[] {GBaseServerSettings.ENDPOINT_STARTUP_CONFIGURATION_PREFIX, serverSettings.Endpoint}); + config.AddCommandLine(new[] + { + GBaseServerSettings.GBASE_ENDPOINT_STARTUP_CONFIGURATION_PREFIX, serverSettings.GBaseEndpoint, + GBaseServerSettings.GBASE_TABLE_ENDPOINT_STARTUP_CONFIGURATION_PREFIX, serverSettings.GBaseTableEndpoint, + GBaseServerSettings.GBASE_ENTRY_ENDPOINT_STARTUP_CONFIGURATION_PREFIX, serverSettings.GBaseEntryEndpoint + }); }) .UseStartup(); }