- add endpoints for base, table and entry

pull/26/head
Simon Gockner 6 years ago
parent 4acf0bc23b
commit 1a3c221b4e
  1. 4
      GBase.Api/Communication/ICommunicationSettings.cs
  2. 15
      GBase.Client/GBaseClientSettings.cs
  3. 4
      GBase.Client/Interfaces/IGBaseClientSettings.cs
  4. 41
      GBase.Server/GBaseServerSettings.cs
  5. 7
      GBase.Server/Program.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; }
}
}

@ -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}";
}
}

@ -8,6 +8,8 @@ namespace GBase.Client.Interfaces
{
public interface IGBaseClientSettings : ICommunicationSettings
{
string ServerProtocolEndpointAddress { get; }
string ServerProtocolGBaseEndpointAddress { get; }
string ServerProtocolGBaseTableEndpointAddress { get; }
string ServerProtocolGBaseEntryEndpointAddress { get; }
}
}

@ -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<GBaseServerSettings>($"{PROTOCOL_ARGUMENT_PREFIX}: The used protocol (e.g 'http' or 'https')");
await Log.Write<GBaseServerSettings>($"{IP_ADDRESS_ARGUMENT_PREFIX}: The used ip address");
await Log.Write<GBaseServerSettings>($"{PORT_ARGUMENT_PREFIX}: The used port");
await Log.Write<GBaseServerSettings>($"{ENDPOINT_ARGUMENT_PREFIX}: The used endpoint");
await Log.Write<GBaseServerSettings>($"{ENDPOINT_ARGUMENT_PREFIX}: The used GBase endpoint");
await Log.Write<GBaseServerSettings>($"{TABLE_ENDPOINT_ARGUMENT_PREFIX}: The used GBase table endpoint");
await Log.Write<GBaseServerSettings>($"{ENTRY_ENDPOINT_ARGUMENT_PREFIX}: The used GBase entry endpoint");
await Log.Write<GBaseServerSettings>("");
await Log.Write<GBaseServerSettings>("Optional Arguments:");
await Log.Write<GBaseServerSettings>($"{LOG_FILE_PATH_ARGUMENT_PREFIX}: The path to the server log file (default: '{_defaultLogFilePath}')");

@ -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<Startup>();
}

Loading…
Cancel
Save