diff --git a/README.md b/README.md index f21aa5e..8798bfa 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Once running the following endpoints will now be available: * http://localhost:5003 - MVC * http://localhost:5005 - BlazorServer -## Running tests with playwrite +## Running tests with PlayWright Install the CLI tooling. ``` diff --git a/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxy.cs b/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxy.cs index 42a160e..d57d77d 100644 --- a/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxy.cs +++ b/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxy.cs @@ -7,23 +7,23 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Yarp.ReverseProxy.Service.Proxy; +using Yarp.ReverseProxy.Forwarder; namespace ReCode.Cocoon.Proxy.Proxy { public class CocoonProxy { private static readonly ActivitySource Source = new("ReCode.Cocoon.Proxy"); - private readonly IHttpProxy _httpProxy; + private readonly IHttpForwarder _httpProxy; private readonly HashSet _backendUrls; private readonly HttpMessageInvoker _httpClient; private readonly RedirectTransformer _transformer; - private readonly RequestProxyOptions _requestOptions; + private readonly ForwarderRequestConfig _requestOptions; private readonly string _destinationPrefix; - public CocoonProxy(IConfiguration configuration, ILogger logger, IHttpProxy httpProxy, CocoonProxyOptions? proxyOptions) + public CocoonProxy(IConfiguration configuration, ILogger logger, IHttpForwarder httpForwarder, CocoonProxyOptions? proxyOptions) { - _httpProxy = httpProxy; + _httpProxy = httpForwarder; _destinationPrefix = configuration .GetValue("Cocoon:Proxy:DestinationPrefix"); @@ -37,7 +37,7 @@ public CocoonProxy(IConfiguration configuration, ILogger logger, IH throw new InvalidOperationException("Invalid DestinationPrefix"); } - logger.LogInformation($"Cocoon Proxy backend: {destinationPrefixUri}"); + logger?.LogInformation($"Cocoon Proxy backend: {destinationPrefixUri}"); _backendUrls = CocoonProxyExclusions.CreateExclusionSet(configuration); @@ -62,9 +62,9 @@ public CocoonProxy(IConfiguration configuration, ILogger logger, IH { timeout = TimeSpan.FromSeconds(30); } - _requestOptions = new RequestProxyOptions + _requestOptions = new ForwarderRequestConfig { - Timeout = timeout + ActivityTimeout = timeout }; } @@ -79,7 +79,7 @@ public async Task ProxyAsync(HttpContext httpContext) using var activity = Source.StartActivity("Proxy"); activity?.SetTag("path", httpContext.Request.Path.ToString()); - await _httpProxy.ProxyAsync(httpContext, _destinationPrefix, _httpClient, _requestOptions, _transformer); + await _httpProxy.SendAsync(httpContext, _destinationPrefix, _httpClient, _requestOptions, _transformer); } } } \ No newline at end of file diff --git a/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxyServicesExtensions.cs b/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxyServicesExtensions.cs index ca94bea..cf23526 100644 --- a/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxyServicesExtensions.cs +++ b/main/src/ReCode.Cocoon.Proxy/Proxy/CocoonProxyServicesExtensions.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using ReCode.Cocoon.Proxy.Proxy; -using Yarp.ReverseProxy.Service.Proxy; +using Yarp.ReverseProxy.Forwarder; // ReSharper disable once CheckNamespace namespace Microsoft.Extensions.DependencyInjection @@ -18,7 +18,7 @@ public static IReverseProxyBuilder AddCocoonProxy(this IServiceCollection servic services.AddSingleton(provider => new CocoonProxy( configuration, provider.GetService>(), - provider.GetService(), cocoonProxyOptions)); + provider.GetService(), cocoonProxyOptions)); return ReverseProxyBuilder(services, configuration); } diff --git a/main/src/ReCode.Cocoon.Proxy/Proxy/RedirectTransformer.cs b/main/src/ReCode.Cocoon.Proxy/Proxy/RedirectTransformer.cs index d4db481..ecbb932 100644 --- a/main/src/ReCode.Cocoon.Proxy/Proxy/RedirectTransformer.cs +++ b/main/src/ReCode.Cocoon.Proxy/Proxy/RedirectTransformer.cs @@ -2,7 +2,7 @@ using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Yarp.ReverseProxy.Service.Proxy; +using Yarp.ReverseProxy.Forwarder; namespace ReCode.Cocoon.Proxy.Proxy { @@ -15,7 +15,7 @@ public RedirectTransformer(Uri destinationPrefix) _destinationPrefix = destinationPrefix; } - public override async Task TransformResponseAsync(HttpContext context, HttpResponseMessage response) + public override ValueTask TransformResponseTrailersAsync(HttpContext context, HttpResponseMessage response) { var location = response.Headers.Location; @@ -24,7 +24,7 @@ public override async Task TransformResponseAsync(HttpContext context, HttpRespo var relative = location.PathAndQuery; response.Headers.Location = new Uri(relative, UriKind.Relative); } - await base.TransformResponseAsync(context, response); + return base.TransformResponseTrailersAsync(context, response); } } } \ No newline at end of file diff --git a/main/src/ReCode.Cocoon.Proxy/ReCode.Cocoon.Proxy.csproj b/main/src/ReCode.Cocoon.Proxy/ReCode.Cocoon.Proxy.csproj index 1a38af6..bc6202e 100644 --- a/main/src/ReCode.Cocoon.Proxy/ReCode.Cocoon.Proxy.csproj +++ b/main/src/ReCode.Cocoon.Proxy/ReCode.Cocoon.Proxy.csproj @@ -13,7 +13,7 @@ - +