NOMAD-Live / nomad-live-api

http://api.nomadlive.tv
GNU General Public License v3.0
0 stars 0 forks source link

Use auth in server header. #3

Open cadesalaberry opened 9 years ago

cadesalaberry commented 9 years ago

Check the docs http://mcavage.me/node-restify/

Should look like this:

var restify = require('restify');

function customAuth(req, res, next) {
  if (req.header('X-Custom-Auth') == "the right one") {
    next();
  } else {
    res.json(401, {code:401, message: "Auth failed."});
    next();
  }

  restify.use(customAuth);
}