2

I've installed Recess:

http://www.recessframework.org/

Configured the database, added a table, generated model and controller.

In video tutorial you can see author uses URI like ../something.json to get JSON results. I generated a profile class so i navigate to ../profile.json, but get an error:

Unable to provide desired content-type. Does the view XXX exist?

Basically what i need is a proper formed Restful JSON service for a use in Ember.js.

I would love it if Recess return JSON without adding .json.

Have anyone of you know how to make it work? How to make a JSON Restful service with Recess properly?

Recess forum is down, so you are only help.

4

1 回答 1

3

您需要修改控制器类以允许它以 JSON 格式输出数据

/**
 * !RespondsWith Json, Layouts
 * !Prefix something/
 */

如果您想摆脱将 .json 添加到请求 URL - 只需将 Json 保留为单个可能的输出:

/**
 * !RespondsWith Json
 * !Prefix something/
 */

有关详细信息,请参阅此链接

另一方面,您可以Accept: application/json在 HTTP 请求中使用标头强制 JSON 输出,因此不应将 .json 单词添加到请求 URL。但是,您仍然需要在控制器类中启用 Json 输出。

于 2013-08-29T19:30:27.773 回答