Rest 通过http返回资源版本历史记录的适当格式是什么
我正在设计一个RESTfulWeb服务,它提供一个版本化的资源。 用于返回的适当返回格式(内容类型)是什么?RFC5829描述了返回格式,但不建议返回格式 首先,我们假设您有一个URL,指向资源的每个版本,如中所示:Rest 通过http返回资源版本历史记录的适当格式是什么,rest,http,version-control,rfc,Rest,Http,Version Control,Rfc,我正在设计一个RESTfulWeb服务,它提供一个版本化的资源。 用于返回的适当返回格式(内容类型)是什么?RFC5829描述了返回格式,但不建议返回格式 首先,我们假设您有一个URL,指向资源的每个版本,如中所示: /path/to/resource/ - returns latest /path/to/resource/v1 - returns version v1 /path/to/resource/v2 - returns version v2 因此,您真正想要的是返回链接的
/path/to/resource/ - returns latest
/path/to/resource/v1 - returns version v1
/path/to/resource/v2 - returns version v2
因此,您真正想要的是返回链接的集合。
这方面的最佳表现是
描述了一个类似的东西,称为时间图,并建议使用。
下面给出了一个例子:
我在这里添加了datetime属性(可能不正确),以表示版本时间和使用的格式(这是我个人的偏好)
对于这里提出的两种格式,您可能需要仔细考虑使用什么关系名称——请参阅< /P>接受我自己的答案直到……除非有人提供更好的答案
HTTP/1.1 200 OK
Date: Thu, 21 Jan 2010 00:06:50 GMT
Server: Apache
Content-Length: 4883
Content-Type: application/link-format
Connection: close
<http://a.example.org>;rel="original",
<http://arxiv.example.net/timemap/http://a.example.org>
; rel="self";type="application/link-format"
; from="Tue, 20 Jun 2000 18:02:59 GMT"
; until="Wed, 09 Apr 2008 20:30:51 GMT",
<http://arxiv.example.net/timegate/http://a.example.org>
; rel="timegate",
<http://arxiv.example.net/web/20000620180259/http://a.example.org>
; rel="first memento";datetime="Tue, 20 Jun 2000 18:02:59 GMT"
; license="http://creativecommons.org/publicdomain/zero/1.0/",
<http://arxiv.example.net/web/20091027204954/http://a.example.org>
; rel="last memento";datetime="Tue, 27 Oct 2009 20:49:54 GMT"
; license="http://creativecommons.org/publicdomain/zero/1.0/",
<http://arxiv.example.net/web/20000621011731/http://a.example.org>
; rel="memento";datetime="Wed, 21 Jun 2000 01:17:31 GMT"
; license="http://creativecommons.org/publicdomain/zero/1.0/",
<http://arxiv.example.net/web/20000621044156/http://a.example.org>
; rel="memento";datetime="Wed, 21 Jun 2000 04:41:56 GMT"
; license="http://creativecommons.org/publicdomain/zero/1.0/",
...
{
"_links": {
"self": { "href": "/versions" },
"first": { "href": "/foobar/version1", "datetime": "2019-01-01T12:00:00Z" },
"memento": { "href": "/foobar/version2", "datetime": "2019-01-02T12:00:00Z" }
"latest": { "href": "/foobar/version3", "datetime": "2019-01-03T12:00:00Z" }
}
}