app.http controllers evaluation is in alphabetical order, causing problem with optional params
Opened this issue · 0 comments
danbord commented
Given the following controller declarations:
app.http("accounts", {..., route: "accounts/{accountId?}/{action?}"})
app.http("products", {..., route: "accounts/{accountId?}/products/{productId?}"})
If we GET
from the following url : /api/accounts/12345/products/
it will end up in the accounts controller with param action="products"
Expected behavior
When evaluating a route, I think the static params should have precedence over the optional ones. Now they are evaluated in alphabetical order (which seems nonsense)
Known workarounds
If we rename the accounts controller "zaccount" (to put after the "products" alphabetical position when evaluating the route). Then its gonna be evaluated first. And both controllers works as planned.