How to add a DEFAULT route?

49 views
Skip to first unread message

Alex Chew

unread,
Aug 8, 2014, 2:14:29 AM8/8/14
to res...@googlegroups.com
Hi,

I want to add a default route to my application. The application can send warning message if a user requests a wrong resource. Thanks.
server.get('/infor',infor.get);//query
server.post('/infor', infor.post);//post new
server.get('/', function(req, res) {
    res.contentType = "json";
    res.send({success:true,message:'It works. Please follow your instructions to request resources. Enjoy!'});
});

//here I want add some code to handle other requests but / or /infor

server.listen(process.env.PORT || port ,/*ip_addr,*/ function(){
    console.log('%s listening at %s ', server.name , server.url);
    console.log('%s listening at %s ', server.name , process.env.PORT || port);
});

 
Reply all
Reply to author
Forward
0 new messages