mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 22:08:17 +08:00
tests passing
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user