mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 03:18:15 +08:00
merged develop
This commit is contained in:
@ -8,6 +8,8 @@ using Ocelot.Library.Infrastructure.UrlPathTemplateRepository;
|
||||
|
||||
namespace Ocelot.Library.Middleware
|
||||
{
|
||||
using System.Net;
|
||||
|
||||
public class ProxyMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
@ -49,9 +51,10 @@ namespace Ocelot.Library.Middleware
|
||||
}
|
||||
}
|
||||
|
||||
if (!urlPathMatch.Match)
|
||||
if (urlPathMatch == null || !urlPathMatch.Match)
|
||||
{
|
||||
throw new Exception("BOOOM TING! no match");
|
||||
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
var upstreamHostUrl = _hostUrlRepository.GetBaseUrlMap(urlPathMatch.DownstreamUrlPathTemplate);
|
||||
|
@ -8,6 +8,11 @@ using Ocelot.Library.Middleware;
|
||||
|
||||
namespace Ocelot
|
||||
{
|
||||
using Library.Infrastructure.HostUrlRepository;
|
||||
using Library.Infrastructure.UrlPathMatcher;
|
||||
using Library.Infrastructure.UrlPathReplacer;
|
||||
using Library.Infrastructure.UrlPathTemplateRepository;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
@ -26,7 +31,11 @@ namespace Ocelot
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Add framework services.
|
||||
|
||||
services.AddSingleton<IHostUrlMapRepository, InMemoryHostUrlMapRepository>();
|
||||
services.AddSingleton<IUrlPathToUrlPathTemplateMatcher, UrlPathToUrlPathTemplateMatcher>();
|
||||
services.AddSingleton<IHostUrlMapRepository, InMemoryHostUrlMapRepository>();
|
||||
services.AddSingleton<IUpstreamUrlPathTemplateVariableReplacer, UpstreamUrlPathTemplateVariableReplacer>();
|
||||
services.AddSingleton<IUrlPathTemplateMapRepository, InMemoryUrlPathTemplateMapRepository>();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@ -37,11 +46,6 @@ namespace Ocelot
|
||||
loggerFactory.AddDebug();
|
||||
|
||||
app.UseProxy();
|
||||
//app.Run()
|
||||
// app.Run(async context =>
|
||||
// {
|
||||
// await context.Response.WriteAsync("Hello from Tom");
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user