private async Task InvokeCore(HttpContext context) { var didProxyRequest = await SpaProxy.PerformProxyRequest( context, _httpClient, _baseUriTask, _applicationStoppingToken, proxy404s : false); if (didProxyRequest) { return; } // Not a request we can proxy await _next.Invoke(context); }
public async Task Invoke(HttpContext context) { if (context.Request.Path.StartsWithSegments(_pathPrefix) || _pathPrefixIsRoot) { var didProxyRequest = await SpaProxy.PerformProxyRequest( context, _httpClient, _baseUriTask, _applicationStoppingToken, proxy404s : false); if (didProxyRequest) { return; } } // Not a request we can proxy await _next.Invoke(context); }
public ConditionalProxyMiddleware( RequestDelegate next, string pathPrefix, TimeSpan requestTimeout, Task <Uri> baseUriTask, IApplicationLifetime applicationLifetime) { if (!pathPrefix.StartsWith("/")) { pathPrefix = "/" + pathPrefix; } _next = next; _pathPrefix = pathPrefix; _pathPrefixIsRoot = string.Equals(_pathPrefix, "/", StringComparison.Ordinal); _baseUriTask = baseUriTask; _httpClient = SpaProxy.CreateHttpClientForProxy(requestTimeout); _applicationStoppingToken = applicationLifetime.ApplicationStopping; }