kvz / cakephp-rest-plugin

Discontinued: recent cakephp versions overlap functionality, there also is @ceeram's plugin. Painless REST server Plugin for CakePHP
http://kvz.io/blog/2010/01/13/cakephp-rest-plugin-presentation/
169 stars 37 forks source link

Force response to application/json if request is not .json #10

Open afrittella opened 13 years ago

afrittella commented 13 years ago

Before All thanks for your useful plugin. :)

I've found your comment in "headers" function. It's about on line 645... // Don't know why, but RequestHandler isn't settings // Content-Type right; so using header() for now instead

I was looking for a method to forse json content if the url is not controller.json and I think I've found a solution also for your problem.

If I move $this->headers(); from "initialize()" to "startup()", it works, because RequestHandler->startup() overwrite your changes with his recognized extension (line 244).

If it was correct, maybe it would be useful for updating your plugin.

I've added also some tricks in other functions. If ($ext == 'html') $ext = 'json';

sorry for my bad english! :)