Hi
Today i started learning restify and the first step was to read
http://mcavage.me/node-restify/. As i am pretty familiar to express i was expecting that a lot of stuff would simply work the same way. I wasn't disappointed with my assumption as in the guide there are a number references to express. One is in routing section:"
in 'basic' mode, is pretty much identical to express/sinatra,". Forgive me as I am not familiar with "express basic mode is" but i found restify routing really different from express:
Restify 3.0.2 code:
var restify = require('restify');
var server = restify.createServer();
server.get('/abcd/:b?', function(req,res,next){
console.log("with b")
next();
});
server.get('/abcd/:a?', function(req,res,next){
console.log("with a")
res.send("small");
next();
});
Express 4.12.3 Code :
var express = require('express');
var app = express();
app.get('/abcd/:b?', function(req,res,next){
console.log("with b")
next();
});
app.get('/abcd/:a?', function(req,res,next){
console.log("with a")
res.send("small");
next();
});
var server = app.listen(3000)
So basically when i call:
express:
with b
with a
both printed out on server console
and
200 returned with body being "small"
restify:
404 is returned {"code":"ResourceNotFound","message":"/abcd does not exist"}
For
express:
with b
with a
both printed out on server console
and
200 returned with body being "small"
in restify:
with b
printed out on server console
no reply from Server makes curl hang
Why is all that? Why restify is not calling all matching routes, like express does ? Why restify is not honoring "string" regexpressions "/:a?"
Am i simply missing sth or restify routing is simply working totally different than express
br JM