1602 / compound

MVC framework. Built on Node.JS. Works on server and browser.
http://compoundjs.com
1.6k stars 182 forks source link

custom respondToformat #584

Open kesavkolla opened 11 years ago

kesavkolla commented 11 years ago

I wanted to add custom respondto format for handling msgpack requests. I thought I could write

c.respondTo (format) -> format.msgpack -> c.send buffer.toJSON()

The above code didn't work. Is there any support for responding to custom formats?

Thanks -Kesav

scaarji commented 11 years ago

You can add custom respondTo formats like this:

require('kontroller').Helpers.respondToFormats.push('msgpack')

but you might have to add kontroller as your app dependency

emilianox commented 10 years ago

@scaarji , In which file put that line? I tried in environment but dont work...

scaarji commented 10 years ago

I have not used compound for a while so I don't know if this solution still works. But it should work regardless of where you put it. Try inspecting require('kontroller').Helpers.respondToFormats somewhere in you action to see if your changes worked.