1

我想知道在rails中的respond_with方法中处理http错误的最佳方法是什么:

respond_to :html, :json

# @my_resources = [] 
def index
  respond_with @my_resources
end

此操作以 http 200 状态代码响应。http 204 是对 http 请求的“无内容”响应,似乎更适合客户端原始请求的正确答案(采用 json 格式)。其他请求和响应也会发生相同的行为。

链接 W3 关于 204 响应代码的 raccomendation

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

4

0 回答 0