使用 jsonapi 的配置问题
我打算使用json:api这个规范的,根据其文档:
Client Responsibilities
Clients MUST send all JSON:API data in request documents with the header Content-Type: application/vnd.api+json without any media type parameters.Clients that include the JSON:API media type in their Accept header MUST specify the media type there at least once without any media type parameters.
Clients MUST ignore any parameters for the application/vnd.api+json media type received in the Content-Type header of response documents.
Server Responsibilities
Servers MUST send all JSON:API data in response documents with the header Content-Type: application/vnd.api+json without any media type parameters.Servers MUST respond with a 415 Unsupported Media Type status code if a request specifies the header Content-Type: application/vnd.api+json with any media type parameters.
Servers MUST respond with a 406 Not Acceptable status code if a request’s Accept header contains the JSON:API media type and all instances of that media type are modified with media type parameters.
也就是说Content-Type
和Accept
必须为application/vnd.api+json
,那么是否就是说这里的配置API_STANDARDS_TREE
应该为vnd
,而API_SUBTYPE
呢?这个怎么配置?是否在这里配置了之后我后端的header
就可以为application/vnd.api+json
,而不需要再做其他配置了呢?我看了《RESTful Web APIs》一书,醍醐灌顶,只是目前空有理论,也许还要跳一些坑才能认清这方面理论与实践的差异。
推荐文章: