tests passing

This commit is contained in:
TomPallister
2020-02-09 15:37:27 +00:00
parent 4bd2243f5e
commit 6bd903bc87
7 changed files with 41 additions and 40 deletions

View File

@ -1,27 +0,0 @@
using Ocelot.Logging;
using Ocelot.Middleware;
using System.Threading.Tasks;
namespace Ocelot.DownstreamMethodTransformer.Middleware
{
public class DownstreamMethodTransformerMiddleware : OcelotMiddleware
{
private readonly OcelotRequestDelegate _next;
public DownstreamMethodTransformerMiddleware(OcelotRequestDelegate next, IOcelotLoggerFactory loggerFactory)
: base(loggerFactory.CreateLogger<DownstreamMethodTransformerMiddleware>())
{
_next = next;
}
public async Task Invoke(DownstreamContext context)
{
if (context.DownstreamReRoute.DownstreamHttpMethod != null)
{
context.DownstreamRequest.Method = context.DownstreamReRoute.DownstreamHttpMethod;
}
await _next.Invoke(context);
}
}
}

View File

@ -2,7 +2,6 @@
using Ocelot.Authorisation.Middleware;
using Ocelot.Cache.Middleware;
using Ocelot.Claims.Middleware;
using Ocelot.DownstreamMethodTransformer.Middleware;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamUrlCreator.Middleware;
using Ocelot.Errors.Middleware;
@ -69,9 +68,6 @@ namespace Ocelot.Middleware.Pipeline
// Initialises downstream request
builder.UseDownstreamRequestInitialiser();
//change Http Method
builder.UseMiddleware<DownstreamMethodTransformerMiddleware>();
// We check whether the request is ratelimit, and if there is no continue processing
builder.UseRateLimiting();

View File

@ -34,6 +34,11 @@ namespace Ocelot.Request.Middleware
context.DownstreamRequest = _creator.Create(downstreamRequest.Data);
if (!string.IsNullOrEmpty(context.DownstreamReRoute?.DownstreamHttpMethod))
{
context.DownstreamRequest.Method = context.DownstreamReRoute.DownstreamHttpMethod;
}
await _next.Invoke(context);
}
}

View File

@ -1,5 +1,3 @@
using Microsoft.AspNetCore.Builder;
using Ocelot.DownstreamUrlCreator.Middleware;
using Ocelot.Middleware.Pipeline;
namespace Ocelot.Request.Middleware
@ -8,8 +6,7 @@ namespace Ocelot.Request.Middleware
{
public static IOcelotPipelineBuilder UseDownstreamRequestInitialiser(this IOcelotPipelineBuilder builder)
{
return builder.UseMiddleware<DownstreamRequestInitialiserMiddleware>()
.UseMiddleware<DownstreamMethodTransformerMiddleware>();
return builder.UseMiddleware<DownstreamRequestInitialiserMiddleware>();
}
}
}