Force JSON output and ignore any kind of content negotiation

Skip to first unread message

Travis Bell

Mar 4, 2014, 12:40:14 PM3/4/14
Hey guys,

I have this as a simple little proxy:

And while I understand this auto negotiates the content type (via the Accept header), we have many clients who don't have this set properly so we've historically had to force it to JSON no matter what. Since our API only returns JSON, this is a fairly safe thing for us to do.

This proxy works fine with cURL, but if I request it in Safari for example, I get:

[:error, "{\"status_code\"=>7, \"status_message\"=>\"Request Timed Out\"}"]

How can I skip the auto-negotiating nature of this and force it? Safari is a good example if a client that is apparently negotiating plain text.


Ilya Grigorik

Mar 4, 2014, 3:47:04 PM3/4/14
Remove render middleware? If you do though, you're on your own to force /
negotiate the right response.

As a rule of thumb, if you're using "render" you probably also want to use
the DefaultMimeType middleware:


You received this message because you are subscribed to the Google Groups "" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Travis Bell

Mar 5, 2014, 9:46:35 AM3/5/14
Ok, thanks Ilya.

I was hoping to use the stuff that was already built but it's not a big deal having to do it on my own.

Reply all
Reply to author
0 new messages