From 77c390f2546bde1985696a9394de840ac930e970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Tue, 24 Jan 2023 15:13:04 +0100 Subject: [PATCH] Convert SelectUrl definition to accept url overrides from config --- .../Net/ConnectedServerOps.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Connected.ServiceModel.Client/Net/ConnectedServerOps.cs b/src/Connected.ServiceModel.Client/Net/ConnectedServerOps.cs index f6f64d3..c9f4131 100644 --- a/src/Connected.ServiceModel.Client/Net/ConnectedServerOps.cs +++ b/src/Connected.ServiceModel.Client/Net/ConnectedServerOps.cs @@ -1,19 +1,29 @@ using Connected.Services; +using Microsoft.Extensions.Configuration; namespace Connected.ServiceModel.Client.Net; internal sealed class SelectUrl : ServiceFunction { - private const string Root = "https://localhost:61599";//"https://connected.tompit.com"; - protected override async Task OnInvoke() + private const string Root = "https://connected.tompit.com"; + private readonly string? _rootOverride = null; + + public SelectUrl(IConfiguration configuration) + { + _rootOverride = configuration?.GetValue("connectedServicesRootUrl", null); + } + + private string RootUrl => string.IsNullOrWhiteSpace(_rootOverride) ? Root : _rootOverride; + + protected override async Task OnInvoke() { await Task.CompletedTask; return Arguments.Kind switch { - ConnectedUrlKind.Root => Root, - ConnectedUrlKind.FileSystem => $"{Root}/services/fileSystem", - ConnectedUrlKind.TableStorage => $"{Root}/services/tables", + ConnectedUrlKind.Root => RootUrl, + ConnectedUrlKind.FileSystem => $"{RootUrl}/services/fileSystem", + ConnectedUrlKind.TableStorage => $"{RootUrl}/services/tables", _ => throw new NotImplementedException(), }; }