mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-05-02 19:42:51 +08:00
18 lines
553 B
C#
18 lines
553 B
C#
using System.Text.RegularExpressions;
|
|
using Ocelot.Responses;
|
|
|
|
namespace Ocelot.DownstreamRouteFinder.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));
|
|
}
|
|
}
|
|
}
|