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