Feature/base url in config (#234)

* started moving baseurl to config issue 233

* fixed test
This commit is contained in:
Tom Pallister
2018-02-15 09:52:16 +00:00
committed by GitHub
parent d6a86b9295
commit bf3188020a
9 changed files with 64 additions and 48 deletions

View File

@ -11,8 +11,10 @@ namespace Ocelot.Configuration.File
public string RequestIdKey { get; set; }
public FileServiceDiscoveryProvider ServiceDiscoveryProvider {get;set;}
public FileServiceDiscoveryProvider ServiceDiscoveryProvider { get;set; }
public FileRateLimitOptions RateLimitOptions { get; set; }
public string BaseUrl { get ;set; }
}
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
@ -6,6 +7,7 @@ namespace Ocelot.DependencyInjection
{
public static class ConfigurationBuilderExtensions
{
[Obsolete("Please set BaseUrl in configuration.json GlobalConfiguration.BaseUrl")]
public static IConfigurationBuilder AddOcelotBaseUrl(this IConfigurationBuilder builder, string baseUrl)
{
var memorySource = new MemoryConfigurationSource();

View File

@ -13,9 +13,11 @@ namespace Ocelot.Middleware
public string Find()
{
var baseUrl = _config.GetValue("BaseUrl", "");
//tries to get base url out of file...
var baseUrl = _config.GetValue("GlobalConfiguration:BaseUrl", "");
return string.IsNullOrEmpty(baseUrl) ? "http://localhost:5000" : baseUrl;
//falls back to memory config then finally default..
return string.IsNullOrEmpty(baseUrl) ? _config.GetValue("BaseUrl", "http://localhost:5000") : baseUrl;
}
}
}