user3154653
user3154653

Reputation: 233

YARP - Routing based on regular expression

Is it possible to use regular expressions in Match-Path-rules to match general broader url-patterns and to be able to match very specific patterns. I dont want to use {**catch-all} but for example an ordinary RegExp like /api/\w{1,3}-\d{1,9} ...

Is this possible to achieve with Yarp in some way?

"Match": {
        "Path": "<Regular expressions here or ?>"
    }

Upvotes: 2

Views: 2556

Answers (1)

drlivsi
drlivsi

Reputation: 162

You can write something like this:

"Match": {
   "Path": "/api/{path:regex(\\w{{1,3}}-\\d{{1,9}})}"
}

or

"Match": {
   "Path": "/api/{folder1:regex(^\\w{{1,3}}$)}-{folder2:regex(^\\d{{1,9}}$)}"
}

Upvotes: 2

Related Questions