-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to disable built-in formatters? #713
Comments
if you pass a set of formatters in to your server: restify.createServer({
formatters: {
'application/javascript; q=0.1': require('./your-jsonp'),
'application/json; q=0.4': require('./your-json'),
'text/plain; q=0.3': require('./your-text'),
'application/octet-stream; q=0.2': require('./your-binary')
}
}); You should be able to set the q values lower than the built ins, which will pick yours over the built ins. |
@micahr but what about actually disabling these response types? I don't have my own to replace them with, I just want restify to return a 406 like it does with any other unsupported type. |
I believe if you pass in a formatters property when creating the server that doesn't have a specific mime-type, that will accomplish what you are looking for. For Example, this would only allow var javascriptFormatter = require('restify').formatters['application/javascript; q=0.1'];
restify.createServer({
formatters: {
'application/javascript; q=0.1': javascriptFormatter
}
}); |
Unfortunately, that is not the case (at least in 2.8.5). |
We have created our own formatters for various response types (json, xml, html). I want to exclusively use these custom formatters and not allow the use of the built-in restify formatters which are still allowing requests with an accept header of
appliction/octet-stream
ortext/plain
for example to get through. How can I remove these built-in formatters from my restify instance?The text was updated successfully, but these errors were encountered: