Skip to content

Commit

Permalink
Workaround broken .NET 9.0 HttpSys linux packages (#2673)
Browse files Browse the repository at this point in the history
* Workaround broken .NET 9.0 HttpSys linux packages

* Also handle the interface being referenced in cross-plat logic
  • Loading branch information
MihaZupan authored Dec 5, 2024
1 parent 40b5a62 commit eac3441
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ReverseProxy/Delegation/DummyHttpSysDelegator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Yarp.ReverseProxy.Delegation;

// Only used as part of a workaround for https://github.com/dotnet/aspnetcore/issues/59166.
internal sealed class DummyHttpSysDelegator : IHttpSysDelegator
{
public void ResetQueue(string queueName, string urlPrefix) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Logging;
using Yarp.ReverseProxy.Configuration;
using Yarp.ReverseProxy.Configuration.ConfigProvider;
using Yarp.ReverseProxy.Delegation;
using Yarp.ReverseProxy.Forwarder;
using Yarp.ReverseProxy.Management;
using Yarp.ReverseProxy.Routing;
Expand Down Expand Up @@ -52,10 +53,22 @@ public static IReverseProxyBuilder AddReverseProxy(this IServiceCollection servi
.AddActiveHealthChecks()
.AddPassiveHealthCheck()
.AddLoadBalancingPolicies()
.AddHttpSysDelegation()
.AddDestinationResolver()
.AddProxy();

if (OperatingSystem.IsWindows())
{
// Workaround for https://github.com/dotnet/aspnetcore/issues/59166.
// .NET 9.0 packages for Ubuntu ship a broken Microsoft.AspNetCore.Server.HttpSys assembly.
// Avoid loading types from that assembly on Linux unless the user explicitly tries to do so.
builder.AddHttpSysDelegation();
}
else
{
// Add a no-op delegator in case someone is injecting the interface in their cross-plat logic.
builder.Services.TryAddSingleton<IHttpSysDelegator, DummyHttpSysDelegator>();
}

services.TryAddSingleton<ProxyEndpointFactory>();

services.AddDataProtection();
Expand Down

0 comments on commit eac3441

Please sign in to comment.