mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 17:08:15 +08:00
renamed from service to repository, makes more sense i guess
This commit is contained in:
@ -2,7 +2,7 @@ using Ocelot.Library.Infrastructure.Responses;
|
||||
|
||||
namespace Ocelot.Library.Infrastructure.Services
|
||||
{
|
||||
public interface IRequestDataService
|
||||
public interface IScopedRequestDataRepository
|
||||
{
|
||||
Response Add<T>(string key, T value);
|
||||
Response<T> Get<T>(string key);
|
@ -5,11 +5,11 @@ using Ocelot.Library.Infrastructure.Responses;
|
||||
|
||||
namespace Ocelot.Library.Infrastructure.Services
|
||||
{
|
||||
public class RequestDataService : IRequestDataService
|
||||
public class ScopedRequestDataRepository : IScopedRequestDataRepository
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RequestDataService(IHttpContextAccessor httpContextAccessor)
|
||||
public ScopedRequestDataRepository(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
@ -11,17 +11,17 @@ namespace Ocelot.Library.Middleware
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly IDownstreamRouteFinder _downstreamRouteFinder;
|
||||
private readonly IHttpResponder _responder;
|
||||
private readonly IRequestDataService _requestDataService;
|
||||
private readonly IScopedRequestDataRepository _scopedRequestDataRepository;
|
||||
|
||||
public DownstreamRouteFinderMiddleware(RequestDelegate next,
|
||||
IDownstreamRouteFinder downstreamRouteFinder,
|
||||
IHttpResponder responder,
|
||||
IRequestDataService requestDataService)
|
||||
IScopedRequestDataRepository scopedRequestDataRepository)
|
||||
{
|
||||
_next = next;
|
||||
_downstreamRouteFinder = downstreamRouteFinder;
|
||||
_responder = responder;
|
||||
_requestDataService = requestDataService;
|
||||
_scopedRequestDataRepository = scopedRequestDataRepository;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
@ -36,7 +36,7 @@ namespace Ocelot.Library.Middleware
|
||||
return;
|
||||
}
|
||||
|
||||
_requestDataService.Add("DownstreamRoute", downstreamRoute.Data);
|
||||
_scopedRequestDataRepository.Add("DownstreamRoute", downstreamRoute.Data);
|
||||
|
||||
await _next.Invoke(context);
|
||||
}
|
||||
|
@ -11,23 +11,23 @@ namespace Ocelot.Library.Middleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly IDownstreamUrlTemplateVariableReplacer _urlReplacer;
|
||||
private readonly IRequestDataService _requestDataService;
|
||||
private readonly IScopedRequestDataRepository _scopedRequestDataRepository;
|
||||
private readonly IHttpResponder _responder;
|
||||
|
||||
public DownstreamUrlCreatorMiddleware(RequestDelegate next,
|
||||
IDownstreamUrlTemplateVariableReplacer urlReplacer,
|
||||
IRequestDataService requestDataService,
|
||||
IScopedRequestDataRepository scopedRequestDataRepository,
|
||||
IHttpResponder responder)
|
||||
{
|
||||
_next = next;
|
||||
_urlReplacer = urlReplacer;
|
||||
_requestDataService = requestDataService;
|
||||
_scopedRequestDataRepository = scopedRequestDataRepository;
|
||||
_responder = responder;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
var downstreamRoute = _requestDataService.Get<DownstreamRoute>("DownstreamRoute");
|
||||
var downstreamRoute = _scopedRequestDataRepository.Get<DownstreamRoute>("DownstreamRoute");
|
||||
|
||||
if (downstreamRoute.IsError)
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace Ocelot.Library.Middleware
|
||||
|
||||
var downstreamUrl = _urlReplacer.ReplaceTemplateVariables(downstreamRoute.Data);
|
||||
|
||||
_requestDataService.Add("DownstreamUrl", downstreamUrl);
|
||||
_scopedRequestDataRepository.Add("DownstreamUrl", downstreamUrl);
|
||||
|
||||
await _next.Invoke(context);
|
||||
}
|
||||
|
@ -11,22 +11,22 @@ namespace Ocelot.Library.Middleware
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly IHttpRequester _requester;
|
||||
private readonly IHttpResponder _responder;
|
||||
private readonly IRequestDataService _requestDataService;
|
||||
private readonly IScopedRequestDataRepository _scopedRequestDataRepository;
|
||||
|
||||
public HttpRequesterMiddleware(RequestDelegate next,
|
||||
IHttpRequester requester,
|
||||
IHttpResponder responder,
|
||||
IRequestDataService requestDataService)
|
||||
IScopedRequestDataRepository scopedRequestDataRepository)
|
||||
{
|
||||
_next = next;
|
||||
_requester = requester;
|
||||
_responder = responder;
|
||||
_requestDataService = requestDataService;
|
||||
_scopedRequestDataRepository = scopedRequestDataRepository;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
var downstreamUrl = _requestDataService.Get<string>("DownstreamUrl");
|
||||
var downstreamUrl = _scopedRequestDataRepository.Get<string>("DownstreamUrl");
|
||||
|
||||
if (downstreamUrl.IsError)
|
||||
{
|
||||
|
Reference in New Issue
Block a user