mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-23 00:32:50 +08:00
This commit is contained in:
parent
f16d201906
commit
1e5a20c2f2
@ -55,16 +55,16 @@ namespace Ocelot.DependencyInjection
|
||||
Services.TryAddSingleton<IInternalConfigurationCreator, FileInternalConfigurationCreator>();
|
||||
Services.TryAddSingleton<IInternalConfigurationRepository, InMemoryInternalConfigurationRepository>();
|
||||
Services.TryAddSingleton<IConfigurationValidator, FileConfigurationFluentValidator>();
|
||||
Services.AddSingleton<HostAndPortValidator>();
|
||||
Services.AddSingleton<IReRoutesCreator, ReRoutesCreator>();
|
||||
Services.AddSingleton<IAggregatesCreator, AggregatesCreator>();
|
||||
Services.AddSingleton<IReRouteKeyCreator, ReRouteKeyCreator>();
|
||||
Services.AddSingleton<IConfigurationCreator, ConfigurationCreator>();
|
||||
Services.AddSingleton<IDynamicsCreator, DynamicsCreator>();
|
||||
Services.AddSingleton<ILoadBalancerOptionsCreator, LoadBalancerOptionsCreator>();
|
||||
Services.AddSingleton<ReRouteFluentValidator>();
|
||||
Services.AddSingleton<FileGlobalConfigurationFluentValidator>();
|
||||
Services.AddSingleton<FileQoSOptionsFluentValidator>();
|
||||
Services.TryAddSingleton<HostAndPortValidator>();
|
||||
Services.TryAddSingleton<IReRoutesCreator, ReRoutesCreator>();
|
||||
Services.TryAddSingleton<IAggregatesCreator, AggregatesCreator>();
|
||||
Services.TryAddSingleton<IReRouteKeyCreator, ReRouteKeyCreator>();
|
||||
Services.TryAddSingleton<IConfigurationCreator, ConfigurationCreator>();
|
||||
Services.TryAddSingleton<IDynamicsCreator, DynamicsCreator>();
|
||||
Services.TryAddSingleton<ILoadBalancerOptionsCreator, LoadBalancerOptionsCreator>();
|
||||
Services.TryAddSingleton<ReRouteFluentValidator>();
|
||||
Services.TryAddSingleton<FileGlobalConfigurationFluentValidator>();
|
||||
Services.TryAddSingleton<FileQoSOptionsFluentValidator>();
|
||||
Services.TryAddSingleton<IClaimsToThingCreator, ClaimsToThingCreator>();
|
||||
Services.TryAddSingleton<IAuthenticationOptionsCreator, AuthenticationOptionsCreator>();
|
||||
Services.TryAddSingleton<IUpstreamTemplatePatternCreator, UpstreamTemplatePatternCreator>();
|
||||
@ -92,8 +92,8 @@ namespace Ocelot.DependencyInjection
|
||||
Services.TryAddSingleton<IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>();
|
||||
Services.TryAddSingleton<IPlaceholderNameAndValueFinder, UrlPathPlaceholderNameAndValueFinder>();
|
||||
Services.TryAddSingleton<IDownstreamPathPlaceholderReplacer, DownstreamTemplatePathPlaceholderReplacer>();
|
||||
Services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteFinder>();
|
||||
Services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteCreator>();
|
||||
Services.TryAddSingleton<IDownstreamRouteProvider, DownstreamRouteFinder>();
|
||||
Services.TryAddSingleton<IDownstreamRouteProvider, DownstreamRouteCreator>();
|
||||
Services.TryAddSingleton<IDownstreamRouteProviderFactory, DownstreamRouteProviderFactory>();
|
||||
Services.TryAddSingleton<IHttpRequester, HttpClientHttpRequester>();
|
||||
Services.TryAddSingleton<IHttpResponder, HttpContextResponder>();
|
||||
@ -114,7 +114,7 @@ namespace Ocelot.DependencyInjection
|
||||
Services.TryAddSingleton<OcelotDiagnosticListener>();
|
||||
Services.TryAddSingleton<IMultiplexer, Multiplexer>();
|
||||
Services.TryAddSingleton<IResponseAggregator, SimpleJsonResponseAggregator>();
|
||||
Services.AddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
|
||||
Services.TryAddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
|
||||
Services.TryAddSingleton<IFileConfigurationPollerOptions, InMemoryFileConfigurationPollerOptions>();
|
||||
Services.TryAddSingleton<IAddHeadersToResponse, AddHeadersToResponse>();
|
||||
Services.TryAddSingleton<IPlaceholders, Placeholders>();
|
||||
|
@ -44,7 +44,7 @@ namespace Ocelot.Responder
|
||||
AddHeaderIfDoesntExist(context, new Header("Content-Length", new []{ response.Content.Headers.ContentLength.ToString() }) );
|
||||
}
|
||||
|
||||
context.Response.StatusCode = (int)response.StatusCode;
|
||||
SetStatusCode(context, (int)response.StatusCode);
|
||||
|
||||
context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = response.ReasonPhrase;
|
||||
|
||||
@ -58,9 +58,17 @@ namespace Ocelot.Responder
|
||||
}
|
||||
|
||||
public void SetErrorResponseOnContext(HttpContext context, int statusCode)
|
||||
{
|
||||
SetStatusCode(context, statusCode);
|
||||
}
|
||||
|
||||
private void SetStatusCode(HttpContext context, int statusCode)
|
||||
{
|
||||
if (!context.Response.HasStarted)
|
||||
{
|
||||
context.Response.StatusCode = statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddHeaderIfDoesntExist(HttpContext context, Header httpResponseHeader)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user