mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
hacking away
This commit is contained in:
parent
95fc687e93
commit
159969483b
@ -29,31 +29,37 @@ namespace Ocelot.Middleware
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="builder"></param>
|
/// <param name="builder"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IApplicationBuilder UseOcelot(this IApplicationBuilder builder)
|
public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
var configuration = CreateConfiguration(builder).Result;
|
await CreateAdministrationArea(builder);
|
||||||
|
|
||||||
builder.Map(configuration.AdministrationPath, x =>
|
|
||||||
{
|
|
||||||
x.UseMvc();
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.UseOcelot(new OcelotMiddlewareConfiguration());
|
|
||||||
|
|
||||||
|
|
||||||
|
await builder.UseOcelot(new OcelotMiddlewareConfiguration());
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task CreateAdministrationArea(IApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
var configuration = await CreateConfiguration(builder);
|
||||||
|
|
||||||
|
if(!string.IsNullOrEmpty(configuration.AdministrationPath))
|
||||||
|
{
|
||||||
|
builder.Map(configuration.AdministrationPath, x =>
|
||||||
|
{
|
||||||
|
x.UseMvc();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers Ocelot with a combination of default middlewares and optional middlewares in the configuration
|
/// Registers Ocelot with a combination of default middlewares and optional middlewares in the configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="builder"></param>
|
/// <param name="builder"></param>
|
||||||
/// <param name="middlewareConfiguration"></param>
|
/// <param name="middlewareConfiguration"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IApplicationBuilder UseOcelot(this IApplicationBuilder builder, OcelotMiddlewareConfiguration middlewareConfiguration)
|
public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder builder, OcelotMiddlewareConfiguration middlewareConfiguration)
|
||||||
{
|
{
|
||||||
CreateConfiguration(builder);
|
await CreateAdministrationArea(builder);
|
||||||
|
|
||||||
// This is registered to catch any global exceptions that are not handled
|
// This is registered to catch any global exceptions that are not handled
|
||||||
builder.UseExceptionHandlerMiddleware();
|
builder.UseExceptionHandlerMiddleware();
|
||||||
|
@ -21,7 +21,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_response_200_and_foward_claim_as_header()
|
public void should_return_server_error()
|
||||||
{
|
{
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
@ -29,9 +29,12 @@ namespace Ocelot.AcceptanceTests
|
|||||||
{
|
{
|
||||||
new FileReRoute
|
new FileReRoute
|
||||||
{
|
{
|
||||||
DownstreamPathTemplate = "http://localhost:53876/",
|
DownstreamPathTemplate = "/",
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
UpstreamHttpMethod = "Get"
|
UpstreamHttpMethod = "Get",
|
||||||
|
DownstreamPort = 53876,
|
||||||
|
DownstreamHost = "localhost",
|
||||||
|
DownstreamScheme = "http",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
{
|
{
|
||||||
var runTime = $"{oSDescription}-{osArchitecture}".ToLower();
|
var runTime = $"{oSDescription}-{osArchitecture}".ToLower();
|
||||||
|
|
||||||
var configPath = $"./bin/Debug/netcoreapp{Version}/{runTime}/configuration.json";
|
var configPath = $"./test/Ocelot.AcceptanceTests/bin/Debug/netcoreapp{Version}/{runTime}/configuration.json";
|
||||||
|
|
||||||
return configPath;
|
return configPath;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using CacheManager.Core;
|
using CacheManager.Core;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@ -43,11 +44,11 @@ namespace Ocelot.ManualTest
|
|||||||
services.AddOcelot();
|
services.AddOcelot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||||
|
|
||||||
app.UseOcelot();
|
await app.UseOcelot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user