btcpayserver/BTCPayServer/Hosting/LowercaseTransformer.cs

24 lines
625 B
C#
Raw Normal View History

2022-01-14 20:16:28 +09:00
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace BTCPayServer.Hosting
{
public class LowercaseTransformer : IOutboundParameterTransformer
{
public static void Register(IServiceCollection services)
{
services.AddRouting(opts =>
{
opts.ConstraintMap["lowercase"] = typeof(LowercaseTransformer);
});
}
public string TransformOutbound(object value)
{
if (value is not string str)
return null;
return str.ToLowerInvariant();
}
}
}