mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 16:48:15 +08:00
change to catch not modified response and get config working correctly
This commit is contained in:
@ -86,13 +86,13 @@ namespace Ocelot.Configuration.Creator
|
||||
|
||||
var reRoutes = new List<ReRoute>();
|
||||
|
||||
foreach (var reRoute in _options.Value.ReRoutes)
|
||||
foreach (var reRoute in fileConfiguration.ReRoutes)
|
||||
{
|
||||
var ocelotReRoute = await SetUpReRoute(reRoute, _options.Value.GlobalConfiguration);
|
||||
var ocelotReRoute = await SetUpReRoute(reRoute, fileConfiguration.GlobalConfiguration);
|
||||
reRoutes.Add(ocelotReRoute);
|
||||
}
|
||||
|
||||
return new OcelotConfiguration(reRoutes, _options.Value.GlobalConfiguration.AdministrationPath);
|
||||
return new OcelotConfiguration(reRoutes, fileConfiguration.GlobalConfiguration.AdministrationPath);
|
||||
}
|
||||
|
||||
private async Task<ReRoute> SetUpReRoute(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
|
||||
|
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Models;
|
||||
using Ocelot.Configuration.Provider;
|
||||
|
||||
namespace Ocelot.Configuration.Creator
|
||||
{
|
||||
public static class IdentityServerConfigurationCreator
|
||||
{
|
||||
public static IdentityServerConfiguration GetIdentityServerConfiguration()
|
||||
{
|
||||
var username = Environment.GetEnvironmentVariable("OCELOT_USERNAME");
|
||||
var hash = Environment.GetEnvironmentVariable("OCELOT_HASH");
|
||||
var salt = Environment.GetEnvironmentVariable("OCELOT_SALT");
|
||||
|
||||
return new IdentityServerConfiguration(
|
||||
"admin",
|
||||
false,
|
||||
SupportedTokens.Both,
|
||||
"secret",
|
||||
new List<string> { "admin", "openid", "offline_access" },
|
||||
"Ocelot Administration",
|
||||
true,
|
||||
GrantTypes.ResourceOwnerPassword,
|
||||
AccessTokenType.Jwt,
|
||||
false,
|
||||
new List<User>
|
||||
{
|
||||
new User("admin", username, hash, salt)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using CacheManager.Core;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@ -61,7 +60,7 @@ namespace Ocelot.DependencyInjection
|
||||
services.AddSingleton<IConfigurationValidator, FileConfigurationValidator>();
|
||||
services.AddSingleton<IBaseUrlFinder, BaseUrlFinder>();
|
||||
|
||||
var identityServerConfiguration = GetIdentityServerConfiguration();
|
||||
var identityServerConfiguration = IdentityServerConfigurationCreator.GetIdentityServerConfiguration();
|
||||
|
||||
if(identityServerConfiguration != null)
|
||||
{
|
||||
@ -142,29 +141,5 @@ namespace Ocelot.DependencyInjection
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IdentityServerConfiguration GetIdentityServerConfiguration()
|
||||
{
|
||||
var username = Environment.GetEnvironmentVariable("OCELOT_USERNAME");
|
||||
var hash = Environment.GetEnvironmentVariable("OCELOT_HASH");
|
||||
var salt = Environment.GetEnvironmentVariable("OCELOT_SALT");
|
||||
|
||||
return new IdentityServerConfiguration(
|
||||
"admin",
|
||||
false,
|
||||
SupportedTokens.Both,
|
||||
"secret",
|
||||
new List<string> {"admin", "openid", "offline_access"},
|
||||
"Ocelot Administration",
|
||||
true,
|
||||
GrantTypes.ResourceOwnerPassword,
|
||||
AccessTokenType.Jwt,
|
||||
false,
|
||||
new List<User>
|
||||
{
|
||||
new User("admin", username, hash, salt)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -54,7 +55,10 @@ namespace Ocelot.Responder
|
||||
|
||||
using (Stream stream = new MemoryStream(content))
|
||||
{
|
||||
await stream.CopyToAsync(context.Response.Body);
|
||||
if (response.StatusCode != HttpStatusCode.NotModified)
|
||||
{
|
||||
await stream.CopyToAsync(context.Response.Body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user