[erlang-questions] Static files served through Webmachine
Tue Jul 19 09:43:20 CEST 2011
Rails does check the Accept: header as well, so quite a lot more
processing goes into choosing the correct content-type for a request.
On the XMLHttpRequest (xhr) instance, you can use
xhr.setRequestHeader("Accept", <accept options>) and you can get to
the xhr object via jQuery's beforeSend function to set this.
Have you looked at using sendfile? This is essentially a way of
letting erlang choose which file to send, but getting nginx to
actually send it. You'll need to be proxying through either nginx or
apache, but apart from that it's quite simple. Here's a rundown of how
it works in nginx: http://wiki.nginx.org/XSendfile
On Tue, Jul 19, 2011 at 4:49 AM, Jack Moffitt <jack@REDACTED> wrote:
> > I'm not familiar with Rails doing .json/.html. My understand was Rails used
> > urls like I was wanting to use: domain.com/user/<user-id> -- no .html. Do
> > you mean something else where they use .json/.html?
> Rails will parse the extension as the format, and defaults to HTML I
> believe. So calling /users/1.xml for example would do an XML dump of
> the dump. Similarly, you can do this for .json as well (but by default
> I think it does html and xml).
> This is redundant information due to this information being in HTTP
> headers preferably, but I think they did it as a practical solution
> for XMLHttpRequest, which has a limited ability to set headers.
> But if you did add such a thing, then nginx can easily proxy one and
> not the other or vice versa.
> erlang-questions mailing list
More information about the erlang-questions