新手问题 AMS 针对 JSONAPI 媒体类型的更改问题

smartepsh · August 04, 2016 · 1601 hits

在使用 AMS 的过程中,发现返回的媒体类型一直是application/json,而 JSONAPI 的文档中明确说明他们已注册的媒体类型是vnd.api+json,作为一名强迫症患者,这是不能忍的......

解决方案一

在 initializers 内,

api_mime_types = %W(
  application/vnd.api_json
  text/x-json
  applicaiton/json
)

Mime::Type.register 'applicaiton/vnd.api+json', :json, api_mime_types

效果不错...还简便,不过是替换方案...

解决方案二

这篇文章里的内容,注册一个新的媒体类型。

问题

是不是正规来说,应该使用方法二?或者有没有什么其他的办法?(不要说不使用 AMS...) @jicheng1014 又 at 你了...😂

smartepsh in 使用 Rails 5 创建 API-Only 应用 mention this topic. 05 Aug 11:11
You need to Sign in before reply, if you don't have an account, please Sign up first.