-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to define route.name along with more than one version #1134
Comments
I think the break down here, is that naming routes means the names have to be globally unique, not just by version. If you appended the version to the name, you would be okay. |
It would work with the version (or anything else that would make it a non unique name) appended, but IMHO it wouldn't be semantically correct. I believe that we can have multiple versions for one same scope, behaviour of a API. I will give you an example about why i think about it in that way: Let's suppose that you have some middlewares, and events handlers to work on some basic stuff of a specific api route. |
So, is it a Bug or an intended behaviour? |
In my mind it is a intended behavior which should be changed. I have ran into this behavior many times while trying to have versioned route. |
@DiegoZoracKy Yes, if you're willing to send a PR, that would be appreciated. |
@yunong, i'll try to find some time to tackle this. |
Hooray!
…On 12 January 2017 at 15:44, Diego ZoracKy ***@***.***> wrote:
@yunong <https://github.com/yunong>, i'll try to find some time to tackle
this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1134 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABK2EO23f-NrCJrvEHFggdccaivwsSKbks5rRrrSgaJpZM4IyY3S>
.
|
@yunong it seems that this issue needs to go a bit further. The "name only" is used as a key in some places like To move forward on this path to have more than one handler, one for each version for a route with a same name, i can think about two options: 1 - Everywhere which is an 2 - Keep the current structure as an Object but for the key, always concatenate Note: I haven't looked much of the restify engine yet to estimate the impact of these ideas. I just read |
Why don't we have an object for a route name with keys as the versions. e.g. If I had a GET route "foo": {
"1": ...,
"2": ...,
"3": ...
} If I need to look up a route by version, I simply do |
And then for the case where we haven't defined any version for the route we could have: "foo": {
"default": fn
} or "foo": fn |
@DiegoZoracKy I like the first option. We can then do if (!route[version] || !route[debug]) {
// return 404
} |
Closes: #289 #381 #474 #575 #790 #633 #717 #576 #576 #909 #875 #860 #853 #850 #829 #813 #801 #921 #1101 #1019 #989 #632 #708 #737 #859 #1326 #1327 #927 #1099 #1068 #1040 #1035 #957 #948 #1134 #1136 #1183 #1206 #1286 #1323 > Note: this issue closes _but does not resolve_ the issues listed, we are just tracking them in another medium
In the documentation, we have this snippet, about versioning:
Which works fine. But if we define the
name
property, like:It won't work as expected. Only the first defined route will be registered. In this case we would get a response of
InvalidVersion
forAccept-Version:2.0.0
.However, the array style will work:
I've saw that at
/lib/router.js
, within the functionmount
, which adds a route, you have this:To prevent the creation of a route already registered. But it only checks for the name, which breaks the case in subject. So i believe that it should be checking for the name && version, like:
I've made this changing on the source code, and it fixed the problem of no registering all the routes with different versions for a same name. I thought about send a pull request, but i don't know yet if this change will affect other aspects of the system.
The text was updated successfully, but these errors were encountered: