Receiving JSON requests into the RC.

Hello Guys,

I’m doing some work with Backbone.js at the moment (which was designed to work out of the box with Rails) and it seems that when making requests to the sever it formats the requests as JSON rather than passing the values like a standard http post request would.

However, this means that my handlers are complaining that the values don’t exist in the RC.

Is there an interceptor, or some form of routing option I can enable so these JSON values appear in the RC?

Thanks.

Robert

Hey Robert,

Here’s an interceptor I created for Backbone interactions a while ago: https://gist.github.com/1118410

Ben

Hi Ben,

That is awesome, and works a treat, should perhaps speak to Luis about including something like this in the core framework.

Now, I want to pick your brains about return formats for these requests too.

My handlers are designed to accept standard requests as well as AJAX ones.

With standard requests I pass the user onto the next event, with AJAX i don’t want to do that, I want to format some JSON data and return it.

My current thoughts is to modify your interceptor to set rc.format = ‘json’

This could then be used within the handler to eiether setNextEvent() or renderData() depending on the format of the request.

How do you handle this?

Robert

Dude! Add this to forgebox please