Skip to content
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

Versioned Routes example code does not work. #1641

Closed
dogenius01 opened this issue Apr 9, 2018 · 6 comments
Closed

Versioned Routes example code does not work. #1641

dogenius01 opened this issue Apr 9, 2018 · 6 comments

Comments

@dogenius01
Copy link

dogenius01 commented Apr 9, 2018

#Source Code
http://restify.com/docs/home/

var restify = require('restify');

var server = restify.createServer();

function sendV1(req, res, next) {
res.send('hello: ' + req.params.name);
return next();
}

function sendV2(req, res, next) {
res.send({hello: req.params.name});
return next();
}

var PATH = '/hello/:name';
server.get({path: PATH, version: '1.1.3'}, sendV1);
server.get({path: PATH, version: '2.0.0'}, sendV2);

server.listen(8080);

Bug Report

assert.js:42
throw new errors.AssertionError({
^

AssertionError [ERR_ASSERTION]: Method 'GET' already declared for route '/hello/:'
at Router._insert (/usr/local/globalcdn/zonemaker/node_modules/find-my-way/index.js:208:7)
at Router._on (/usr/local/globalcdn/zonemaker/node_modules/find-my-way/index.js:120:21)
at Router.on (/usr/local/globalcdn/zonemaker/node_modules/find-my-way/index.js:47:8)
at RouterRegistryRadix.add (/usr/local/globalcdn/zonemaker/node_modules/restify/lib/routerRegistryRadix.js:42:21)
at Router.mount (/usr/local/globalcdn/zonemaker/node_modules/restify/lib/router.js:167:20)
at Server.serverMethod [as get] (/usr/local/globalcdn/zonemaker/node_modules/restify/lib/server.js:1476:33)
at Object. (/usr/local/globalcdn/zonemaker/app.js:17:8)
at Module._compile (module.js:612:30)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)

Restify Version

v7.1.0

Node.js Version

v8.8.1

@hekike
Copy link
Member

hekike commented Apr 10, 2018

Fix: #1642

@hekike
Copy link
Member

hekike commented Apr 10, 2018

Released as: v7.1.1, thanks for reporting this!

@hekike hekike closed this as completed Apr 10, 2018
@hekike
Copy link
Member

hekike commented Apr 10, 2018

Please check out the updated example code.

@dogenius01
Copy link
Author

dogenius01 commented Apr 11, 2018

@hekike
Thank you. Now it works.
But, the example code in http://restify.com/docs/home/ is still same.
However, i found an updated one from https://github.com/restify/node-restify/pull/1642/files/fa7c70637f6deddeeea7903d2756fc712e435df5.

Please, update the document for other people. :)
Thank you again.

@hekike
Copy link
Member

hekike commented Apr 11, 2018

Thanks, website updated!

@talatm02
Copy link

Same error in Restify V: 7.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants