Skip to content

Commit

Permalink
feat(超文本驱动): 增加了新设计还不成熟的“超文本驱动”方案
Browse files Browse the repository at this point in the history
  • Loading branch information
bolasblack committed Oct 11, 2014
1 parent 20c9f40 commit e40024a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions SUPPLEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [User-Agent](#user-agent)
* [两步验证](#两步验证)
* [同时操作多个资源](#同时操作多个资源)
* [超文本驱动](#超文本驱动)

## User-Agent

Expand Down Expand Up @@ -120,3 +121,23 @@ Content-Type: application/json-patch+json
```http
HTTP/1.1 204 No Content
```

## 超文本驱动

想法受启发于 [JSON API 方案](http://jsonapi.org/),很多做法基本照搬,主要是把 `links` 相关内容放到了请求头里。

想法目前还不成熟,并不建议投入使用。

```http
HTTP/1.1 200 OK
Link: <http://api.example.com/peoples/{posts.author}>; rel="res:author"; allow="collection,get",
<http://api.example.com/comments/{posts.comments}>; rel="res:comments"; allow="collection,create,get,delete",
<http://api.example.com/todos/order>; rel="res:order"; allow="get,put"
[{
"id": "1",
"title": "Rails is Omakase",
"author": "9",
"comments": [ "5", "12", "17", "20" ]
}]
```

0 comments on commit e40024a

Please sign in to comment.