btcpayserver/BTCPayServer/Hosting/LowercaseTransformer.cs
2022-01-15 14:54:06 +09:00

24 lines
625 B
C#

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();
}
}
}