mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-05-02 21:02:50 +08:00
18 lines
577 B
C#
18 lines
577 B
C#
using System.Text.RegularExpressions;
|
|
using Ocelot.Library.Infrastructure.Responses;
|
|
|
|
namespace Ocelot.Library.Infrastructure.UrlMatcher
|
|
{
|
|
public class RegExUrlMatcher : IUrlPathToUrlTemplateMatcher
|
|
{
|
|
public Response<UrlMatch> Match(string upstreamUrlPath, string upstreamUrlPathTemplate)
|
|
{
|
|
var regex = new Regex(upstreamUrlPathTemplate);
|
|
|
|
return regex.IsMatch(upstreamUrlPath)
|
|
? new OkResponse<UrlMatch>(new UrlMatch(true))
|
|
: new OkResponse<UrlMatch>(new UrlMatch(false));
|
|
}
|
|
}
|
|
}
|