Convert SelectUrl definition to accept url overrides from config
This commit is contained in:
		
							parent
							
								
									db4fac4ce7
								
							
						
					
					
						commit
						77c390f254
					
				@ -1,19 +1,29 @@
 | 
			
		||||
using Connected.Services;
 | 
			
		||||
using Microsoft.Extensions.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Connected.ServiceModel.Client.Net;
 | 
			
		||||
 | 
			
		||||
internal sealed class SelectUrl : ServiceFunction<ConnectedServerUrlArgs, string>
 | 
			
		||||
{
 | 
			
		||||
	private const string Root = "https://localhost:61599";//"https://connected.tompit.com";
 | 
			
		||||
	protected override async Task<string?> OnInvoke()
 | 
			
		||||
	private const string Root = "https://connected.tompit.com";
 | 
			
		||||
	private readonly string? _rootOverride = null;
 | 
			
		||||
 | 
			
		||||
	public SelectUrl(IConfiguration configuration)
 | 
			
		||||
	{
 | 
			
		||||
		_rootOverride = configuration?.GetValue<string?>("connectedServicesRootUrl", null);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private string RootUrl => string.IsNullOrWhiteSpace(_rootOverride) ? Root : _rootOverride;
 | 
			
		||||
 | 
			
		||||
	protected override async Task<string> 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(),
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user