Azure / Azure/azure-functions-nodejs-library

app.http controllers evaluation is in alphabetical order, causing problem with optional params

Open
#300 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
70
Forks
35
Avg merge
4d 18h
Merged PRs (30d)
6

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.