public async Task Invoke(HttpContext context) { var upstreamUrlPath = context.Request.Path.ToString(); //todo make this getting config its own middleware one day? var configuration = await _configProvider.Get(); if (configuration.IsError) { _logger.LogError($"{MiddlewareName} setting pipeline errors. IOcelotConfigurationProvider returned {configuration.Errors.ToErrorString()}"); SetPipelineError(configuration.Errors); } SetServiceProviderConfigurationForThisRequest(configuration.Data.ServiceProviderConfiguration); _logger.LogDebug("upstream url path is {upstreamUrlPath}", upstreamUrlPath); var downstreamRoute = _downstreamRouteFinder.FindDownstreamRoute(upstreamUrlPath, context.Request.Method, configuration.Data); if (downstreamRoute.IsError) { _logger.LogError($"{MiddlewareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}"); SetPipelineError(downstreamRoute.Errors); return; } _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamPathTemplate); SetDownstreamRouteForThisRequest(downstreamRoute.Data); await _next.Invoke(context); }
public async Task Invoke(HttpContext context) { _logger.LogDebug("started calling downstream route finder middleware"); var upstreamUrlPath = context.Request.Path.ToString().SetLastCharacterAs('/'); _logger.LogDebug("upstream url path is {upstreamUrlPath}", upstreamUrlPath); var downstreamRoute = _downstreamRouteFinder.FindDownstreamRoute(upstreamUrlPath, context.Request.Method); if (downstreamRoute.IsError) { _logger.LogDebug("IDownstreamRouteFinder returned an error, setting pipeline error"); SetPipelineError(downstreamRoute.Errors); return; } _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamPathTemplate); SetDownstreamRouteForThisRequest(downstreamRoute.Data); _logger.LogDebug("calling next middleware"); await _next.Invoke(context); _logger.LogDebug("succesfully called next middleware"); }
public async Task Invoke(HttpContext context) { _logger.TraceMiddlewareEntry(); var upstreamUrlPath = context.Request.Path.ToString().SetLastCharacterAs('/'); _logger.LogDebug("upstream url path is {upstreamUrlPath}", upstreamUrlPath); var downstreamRoute = await _downstreamRouteFinder.FindDownstreamRoute(upstreamUrlPath, context.Request.Method); if (downstreamRoute.IsError) { _logger.LogError($"{MiddlwareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}"); SetPipelineError(downstreamRoute.Errors); _logger.TraceMiddlewareCompleted(); return; } _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamPathTemplate); SetDownstreamRouteForThisRequest(downstreamRoute.Data); _logger.TraceInvokeNext(); await _next.Invoke(context); _logger.TraceInvokeNextCompleted(); _logger.TraceMiddlewareCompleted(); }
public async Task Invoke(DownstreamContext context) { var upstreamUrlPath = context.HttpContext.Request.Path.ToString(); var upstreamHost = context.HttpContext.Request.Headers["Host"]; var configuration = _repo.Get(); if (configuration.IsError) { Logger.LogWarning($"{MiddlewareName} setting pipeline errors. IOcelotConfigurationProvider returned {configuration.Errors.ToErrorString()}"); SetPipelineError(context, configuration.Errors); return; } context.ServiceProviderConfiguration = configuration.Data.ServiceProviderConfiguration; Logger.LogDebug($"Upstream url path is {upstreamUrlPath}"); var downstreamRoute = _downstreamRouteFinder.FindDownstreamRoute(upstreamUrlPath, context.HttpContext.Request.Method, configuration.Data, upstreamHost); if (downstreamRoute.IsError) { Logger.LogWarning($"{MiddlewareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}"); SetPipelineError(context, downstreamRoute.Errors); return; } var downstreamPathTemplates = string.Join(", ", downstreamRoute.Data.ReRoute.DownstreamReRoute.Select(r => r.DownstreamPathTemplate.Value)); Logger.LogDebug($"downstream templates are {downstreamPathTemplates}"); context.TemplatePlaceholderNameAndValues = downstreamRoute.Data.TemplatePlaceholderNameAndValues; await _multiplexer.Multiplex(context, downstreamRoute.Data.ReRoute, _next); }
public async Task Invoke(DownstreamContext context) { var upstreamUrlPath = context.HttpContext.Request.Path.ToString(); var upstreamHost = context.HttpContext.Request.Headers["Host"]; var configuration = await _configProvider.Get(); if (configuration.IsError) { _logger.LogError($"{MiddlewareName} setting pipeline errors. IOcelotConfigurationProvider returned {configuration.Errors.ToErrorString()}"); SetPipelineError(context, configuration.Errors); return; } context.ServiceProviderConfiguration = configuration.Data.ServiceProviderConfiguration; _logger.LogDebug("upstream url path is {upstreamUrlPath}", upstreamUrlPath); var downstreamRoute = _downstreamRouteFinder.FindDownstreamRoute(upstreamUrlPath, context.HttpContext.Request.Method, configuration.Data, upstreamHost); if (downstreamRoute.IsError) { _logger.LogError($"{MiddlewareName} setting pipeline errors. IDownstreamRouteFinder returned {downstreamRoute.Errors.ToErrorString()}"); SetPipelineError(context, downstreamRoute.Errors); return; } //todo - put this back in // _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamReRoute.DownstreamPathTemplate); context.TemplatePlaceholderNameAndValues = downstreamRoute.Data.TemplatePlaceholderNameAndValues; await _multiplexer.Multiplex(context, downstreamRoute.Data.ReRoute, _next); }
private void WhenICallTheFinder() { _result = _downstreamRouteFinder.FindDownstreamRoute(_upstreamUrlPath, _upstreamHttpMethod).Result; }
private void WhenICallTheFinder() { _result = _downstreamRouteFinder.FindDownstreamRoute(_upstreamUrlPath, _upstreamHttpMethod, _config, _upstreamHost); }