Created
February 26, 2014 13:56
-
-
Save spikhoff/9229833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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