-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RequestTransformContext.DestinationPrefix read-write
- Loading branch information
1 parent
3a5a68f
commit d9d6984
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/ReverseProxy.Tests/Transforms/DestinationPrefixTransformTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Yarp.ReverseProxy.Transforms.Tests; | ||
|
||
public class DestinationPrefixTransformTests | ||
{ | ||
[Fact] | ||
public async Task UpdateDestinationPrefix() | ||
{ | ||
const string newDestinationPrefix = "http://localhost:8080"; | ||
var context = new RequestTransformContext() | ||
{ | ||
DestinationPrefix = "http://contoso.com:5000" | ||
}; | ||
var transform = new DestinationPrefixTransform(newDestinationPrefix); | ||
await transform.ApplyAsync(context); | ||
} | ||
|
||
private class DestinationPrefixTransform(string newDestinationPrefix) : RequestTransform | ||
{ | ||
public override ValueTask ApplyAsync(RequestTransformContext context) | ||
{ | ||
context.DestinationPrefix = newDestinationPrefix; | ||
return ValueTask.CompletedTask; | ||
} | ||
} | ||
} |