mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 10:58:15 +08:00
Feature/base url in config (#234)
* started moving baseurl to config issue 233 * fixed test
This commit is contained in:
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user