Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static route should supersede wildcard route

I have an Azure Function with 3 endpoints:

  1. Analyze: /{tenantName}/Analyze
  2. Search: /{tenantName}/Search
  3. GetImage: /{tenantName}/{renditionString?}

When I call the "Search" endpoint, then it hits the "anything" route (number 3) while I would expect it to first hit the static routes and only if they are not matched, then it would hit the route with the wildcard.

When I call the "Analyze" endpoint then it works as expected. Here is a screenshot showing my test.

enter image description here

What exactly determines which endpoint is hit in the route? How do I troubleshoot this?

(I tried many things to confirm the issue, such as removing query parameters and renaming endpoints to something obscure)

Edit

The solution by @hury-shen worked - by changing the method name the alphabetically sorted matching changed and actually affected which path was hit. I am describing it here in addition to his fully satisfactory answer, so I can include a screenshot showing how it looks when solved.

enter image description here

like image 588
Niels Brinch Avatar asked Oct 27 '25 08:10

Niels Brinch


1 Answers

According to some test, it seems the system will check the sequence of the functions and then match the endpoint. In your function app, the function Search comes after the function GetImage. So it will match the endpoint of GetImage first but not match the endpoint of Search.

To solve this problem, I didn't find a way which can set the priority. But we can change the function name easily to meet your requirement. Just change the name of function GetImage from GetImage to ZGetImage, then it will comes after function Search. enter image description here Jsut add a letter Z, it will not change the old path of your functions(as mentioned in your comments).

like image 163
Hury Shen Avatar answered Oct 30 '25 11:10

Hury Shen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!