开发者

CakePHP, Rails respond_to equivalent

开发者 https://www.devze.com 2022-12-24 19:37 出处:网络
What\'s the best way to output different types of responses f.ex xml, json, html, rss etc. in the same controller action, 开发者_如何学运维and how would I send the preferred content-type to the action

What's the best way to output different types of responses f.ex xml, json, html, rss etc. in the same controller action, 开发者_如何学运维and how would I send the preferred content-type to the action?

Ex. rails URLs:

  • /user/add.xml = XML output
  • /user/add.js = JS/JSON output


Having not really tried to achieve this I'm not too sure, but there is a chapter on this in the book, http://book.cakephp.org/view/174/Request-Handling which looks, at a skim, like it might cover what you need. It seems to revolve around processing the type of request.


I think what you want are web services. Lots of resources online.

ow-easy-are-web-services-in-cakephp-12-really-easy

cakephp-and-restful-web-services

0

精彩评论

暂无评论...
验证码 换一张
取 消