-
I have multiple route configurations in ocelot.json
GET http://localhost/V1/List/100/View/256/Records Above GET request matches first route instead of second one. I can resolve this issue by specifying high priority to second one. Here, I expect best match instead of first match. Is there any solution to do so? Specifications
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, There is!
Indeed, the GET request matches the first route rather than the second one because the first route is a Catch All route. A Catch All route is a unique type of routing that attempts to match all content in the last placeholder, including query strings.
Certainly, this is the correct solution. Prioritizing routing is necessary. However, I'm puzzled that implicit priorities were not applied to the CatchAll route, which should have the lowest priority. Perhaps we need to review our design, because the
Seems your route template can be shorter: {
"UpstreamPathTemplate": "/{everything}",
"DownstreamPathTemplate": "/Api/{everything}",
...
} I don't understand, why did you define so long template. Possibly you need to read Routing docs once again. RecommendationDefine one Catch All route! This should solve the problems. {
"UpstreamPathTemplate": "/{everything}",
"DownstreamPathTemplate": "/Api/{everything}",
...
} Hope it helps! |
Beta Was this translation helpful? Give feedback.
Yes, There is!
Indeed, the GET request matches the first route rather than the second one because the first route is a Catch All route. A Catch All route is a unique type of routing that attempts to match all content in the last placeholder, including query strings.
I believe that when multiple routes match a URL, the first one is selected.
Certainly, this is the correct solution. Prioritizing routing is ne…