Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Created May 10, 2013 15:16
Show Gist options
  • Save muhammadghazali/5555076 to your computer and use it in GitHub Desktop.
Save muhammadghazali/5555076 to your computer and use it in GitHub Desktop.
Indent size preference on my JavaScript source code. I preferred to choose indent size with 2 spaces.
/**
* A middleware to check the requested content type.
*/
module.exports.acceptedFormat = function () {
return function (req, res, next) {
res.format({
'application/json': function () {
next();
},
'application/xml': function () {
next();
},
'default': function () {
res.send(406, 'Sorry, we only provide resources in JSON and XML.');
}
});
};
};
/**
* A middleware to check the requested content type.
*/
module.exports.acceptedFormat = function () {
return function (req, res, next) {
res.format({
'application/json': function () {
next();
},
'application/xml': function () {
next();
},
'default': function () {
res.send(406, 'Sorry, we only provide resources in JSON and XML.');
}
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment