Skip to content

Instantly share code, notes, and snippets.

@spikhoff
Created February 26, 2014 13:56
Show Gist options
  • Save spikhoff/9229833 to your computer and use it in GitHub Desktop.
Save spikhoff/9229833 to your computer and use it in GitHub Desktop.
var restify = require('restify');
// create server
var server = restify.createServer();
// Blocks your chain on reading and parsing the HTTP request body.
// Switches on Content-Type and does the appropriate logic.
// application/json, application/x-www-form-urlencoded and multipart/form-data are currently supported.
server.use(restify.bodyParser({rejectUnknown: true}));
server.del('/endpoint', function (req, res, next) {
return next();
});
// create client
var client = restify.createJsonClient({
version: '*',
url: 'http://0.0.0.0:8080'
});
server.listen(8080, function () {
// And here we get UnsupportedMediaTypeError when bodyParser rejectUnknown is set to true.
// JsonClient sends application/octet-stream instead application/json.
client.del('/endpoint', function(err) {
console.log(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment