Skip to content

Commit 091ecc2

Browse files
committed
Move to SF for data model
For #1.
1 parent a759d24 commit 091ecc2

File tree

1 file changed

+31
-111
lines changed

1 file changed

+31
-111
lines changed

draft-ietf-httpapi-link-hint.md

Lines changed: 31 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ normative:
3434
WEB-LINKING: RFC8288
3535
JSON: RFC8259
3636
URI: RFC3986
37+
STRUCTURED-FIELDS: RFC9651
3738

3839

3940
--- abstract
@@ -55,7 +56,7 @@ Hints are just that -- they are not a contract, and are to only be taken as advi
5556

5657
More fine-grained information might also be gathered by interacting with the resource (e.g., via a GET), or by another resource containing it (such as a widgets collection) or describing it (e.g., one linked to it with a "describedby" link relation).
5758

58-
There is not a single way to convey hints with a link; rather, it is expected that this will be done by individual link serialisations (see {{Section 3.4.1 of WEB-LINKING}}). However, {{link_header}} does recommend how to include link hints in the existing Link header field.
59+
There is not a single way to convey hints with a link; rather, it is expected that this will be done by individual link serialisations (see {{Section 3.4.1 of WEB-LINKING}}).
5960

6061

6162
## Notational Conventions
@@ -65,30 +66,9 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S
6566

6667
# HTTP Link Hints {#link_hints}
6768

68-
A HTTP link hint is a (key, value) tuple that describes the target resource of a Web link {{WEB-LINKING}}, or the link itself. The value's canonical form is a JSON {{JSON}} data structure specific to that hint.
69+
A HTTP link hint is a (key, value) tuple that describes the target resource of a Web link {{WEB-LINKING}}, or describes the link itself. The value's canonical form is expressed in subset of the data types defined by HTTP Structured Fields {{STRUCTURED-FIELDS}}.
6970

70-
Typically, link hints are serialised in links as target attributes ({{Section 3.4.1 of WEB-LINKING}}).
71-
72-
In JSON-based formats, this can be achieved by simply serialising link hints as an object; for example:
73-
74-
75-
~~~ json
76-
{
77-
"_links": {
78-
"self": {
79-
"href": "/orders/523",
80-
"hints": {
81-
"allow": ["GET", "POST"],
82-
"accept-post": [
83-
"application/example+json"
84-
]
85-
}
86-
}
87-
}
88-
}
89-
~~~
90-
91-
In other link formats, this requires a mapping from the canonical JSON data model into the constraints of that format. One such mapping is described in {{link_header}} for the Link HTTP header field.
71+
Typically, link hints are serialised in links as target attributes ({{Section 3.4.1 of WEB-LINKING}}). In the Link HTTP Header, this can be done by serialising those attributes as strings. In other link formats, this requires a mapping from the canonical data model into the constraints of that format.
9272

9373
The information in a link hint SHOULD NOT be considered valid for longer than the freshness lifetime ({{Section 4.2 of HTTP-CACHING}}) of the representation that the link occurred within, and in some cases, it might be valid for a considerably shorter period.
9474

@@ -102,89 +82,79 @@ Likewise, the information in a link hint is specific to the link it is attached
10282

10383
* Hint Name: allow
10484
* Description: Hints the HTTP methods that can be used to interact with the target resource; equivalent to the Allow HTTP response header.
105-
* Content Model: array (of strings)
85+
* Content Model: Inner List of Strings
10686
* Specification: \[this document]
10787

108-
Content MUST be an array of strings, containing HTTP methods ({{Section 9 of HTTP}}).
88+
Content MUST be a Inner List of Strings, containing HTTP methods ({{Section 9 of HTTP}}).
10989

11090
## formats
11191

11292
* Hint Name: formats
11393
* Description: Hints the representation type(s) that the target resource can produce and consume, using the GET and PUT (if allowed) methods respectively.
114-
* Content Model: array (of strings)
94+
* Content Model: Inner List of Strings
11595
* Specification: \[this document]
11696

117-
Content MUST be an array of strings, containing media types ({{Section 8.3.1 of HTTP}}).
97+
Content MUST be a Inner List of Strings, containing media types ({{Section 8.3.1 of HTTP}}).
11898

11999
## accept-post
120100

121101
* Hint Name: accept-post
122102
* Description: Hints the POST request format(s) that the target resource can consume.
123-
* Content Model: array (of strings)
103+
* Content Model: Inner List of Strings
124104
* Specification: \[this document]
125105

126-
Content MUST be an array of strings, with the same constraints as for "formats".
106+
Content MUST be a Inner List of Strings, with the same constraints as for "formats".
127107

128-
When this hint is present, "POST" SHOULD be listed in the "allow" hint.
108+
When this hint is present, "POST" SHOULD be listed in the "allow" hint when present.
129109

130110
## accept-patch
131111

132112
* Hint Name: accept-patch
133113
* Description: Hints the PATCH {{!RFC5789}} request format(s) that the target resource can consume; equivalent to the Accept-Patch HTTP response header.
134-
* Content Model: array (of strings)
114+
* Content Model: Inner List of Strings
135115
* Specification: \[this document]
136116

137-
Content MUST be an array of strings, containing media types ({{Section 8.3.1 of HTTP}}) that identify the acceptable patch formats.
117+
Content MUST be a Inner List of Strings, containing media types ({{Section 8.3.1 of HTTP}}) that identify the acceptable patch formats.
138118

139-
When this hint is present, "PATCH" SHOULD be listed in the "allow" hint.
119+
When this hint is present, "PATCH" SHOULD be listed in the "allow" hint when present.
140120

141121
## accept-ranges
142122

143123
* Hint Name: accept-ranges
144124
* Description: Hints the range-specifier(s) available for the target resource; equivalent to the Accept-Ranges HTTP response header {{HTTP}}.
145-
* Content Model: array (of strings)
125+
* Content Model: Inner List of Strings
146126
* Specification: \[this document]
147127

148-
Content MUST be an array of strings, containing HTTP ranges-specifiers ({{Section 14.1.1 of HTTP}}).
128+
Content MUST be a Inner List of Strings, containing HTTP ranges-specifiers ({{Section 14.1.1 of HTTP}}).
149129

150130
## accept-prefer
151131

152132
* Hint Name: accept-prefer
153133
* Description: Hints the preference(s) {{!RFC7240}} that the target resource understands (and might act upon) in requests.
154-
* Content Model: array (of strings)
134+
* Content Model: Inner List of Strings
155135
* Specification: \[this document]
156136

157-
Content MUST be an array of strings, contain preferences ({{Section 2 of RFC7240}}). Note that, by its nature, a preference can be ignored by the server.
137+
Content MUST be a Inner List of Strings, containing preferences ({{Section 2 of RFC7240}}). Note that, by its nature, a preference can be ignored by the server.
158138

159139
## precondition-req
160140

161141
* Hint Name: precondition-req
162142
* Description: Hints that the target resource requires state-changing requests (e.g., PUT, PATCH) to include a precondition, as per {{Section 13.1 of HTTP}}, to avoid conflicts due to concurrent updates.
163-
* Content Model: array (of strings)
143+
* Content Model: Inner List of Strings
164144
* Specification: \[this document]
165145

166-
Content MUST be an array of strings, with possible values "etag" and "last-modified" indicating type of precondition expected.
146+
Content MUST be a Inner List of Strings, with possible values "etag" and "last-modified" indicating type of precondition expected.
167147

168148
See also the 428 Precondition Required status code ({{!RFC6585}}).
169149

170150
## auth-schemes
171151

172152
* Hint Name: auth-schemes
173153
* Description: Hints that the target resource requires authentication using the HTTP Authentication framework {{Section 11 of HTTP}}.
174-
* Content Model: array (of strings)
154+
* Content Model: Inner List of Strings
175155
* Specification: \[this document]
176156

177-
Content MUST be an array of strings, each corresponding to a HTTP authentication scheme ({{Section 11.1 of HTTP}}), and optionally a "realms" member containing an array of zero to many strings that identify protection spaces that the resource is a member of.
178-
179-
For example:
180-
181-
~~~ json
182-
{
183-
"auth-schemes": [
184-
"Basic", "Digest"
185-
]
186-
}
187-
~~~
157+
Content MUST be a Inner List of Strings, each corresponding to a HTTP authentication scheme ({{Section 11.1 of HTTP}}), and optionally a "realms" member containing an array of zero to many strings that identify protection spaces that the resource is a member of.
188158

189159
## auth-realms
190160

@@ -195,27 +165,17 @@ For example:
195165

196166
Content MUST be an array of strings, each indicating a protection space that the resource is a member of.
197167

198-
For example:
199-
200-
~~~ json
201-
{
202-
"auth-realms": [
203-
"private"
204-
]
205-
}
206-
~~~
207-
208168
## status
209169

210170
* Hint Name: status
211171
* Description: Hints the status of the target resource.
212-
* Content Model: string
172+
* Content Model: Token
213173
* Specification: \[this document]
214174

215-
Content MUST be a string; possible values are:
175+
Content MUST be a Token; possible values are:
216176

217-
* "deprecated" - indicates that use of the resource is not recommended, but it is still available.
218-
* "gone" - indicates that the resource is no longer available; i.e., it will return a 410 (Gone) HTTP status code if accessed.
177+
* deprecated - indicates that use of the resource is not recommended, but it is still available.
178+
* gone - indicates that the resource is no longer available; i.e., it will return a 410 (Gone) HTTP status code if accessed.
219179

220180

221181

@@ -234,65 +194,25 @@ Link hints are generic; that is, they are potentially applicable to any HTTP res
234194

235195
Hint names MUST be composed of the lowercase letters (a-z), digits (0-9), underscores ("_") and hyphens ("-"), and MUST begin with a lowercase letter.
236196

237-
Hint content MUST be described in terms of JSON values ({{Section 3 of JSON}}).
197+
Hint content MUST be described using valid combinations of the following types defined by HTTP Structured Fields ({{STRUCTURED-FIELDS}}):
198+
199+
* Inner List ({{Section 3.1.2 of STRUCTURED-FIELDS}})
200+
* Item ({{Section 3.3 of STRUCTURED-FIELDS}})
238201

239202
Hint semantics SHOULD be described in terms of the framework defined in {{WEB-LINKING}}.
240203

241204
New hints are registered using the Expert Review process described in {{?RFC8126}} to enforce the criteria above. Requests for registration of new resource hints are to use the following template:
242205

243206
* Hint Name: \[hint name]
244207
* Description: \[a short description of the hint's semantics]
245-
* Content Model: \[valid JSON value types; see RFC627 Section 2.1]
208+
* Content Model: \[allowed Structured Fields types]
246209
* Specification: \[reference to specification document]
247210

248211
Initial registrations are enumerated in {{hints}}. The "rel", "rev", "hreflang", "media", "title", and "type" hint names are reserved, so as to avoid potential clashes with link serialisations.
249212

250213

251214
--- back
252215

253-
# Representing Link Hints in Link Headers {#link_header}
254-
255-
A link hint can be represented in a Link header ({{Section 3 of WEB-LINKING}}) as a link-extension.
256-
257-
When doing so, the JSON of the hint's content SHOULD be normalised to reduce extraneous spaces (%x20), and MUST NOT contain horizontal tabs (%x09), line feeds (%x0A) or carriage returns (%x0D). When they are part of a string value, these characters MUST be escaped as described in {{Section 7 of JSON}}; otherwise, they MUST be discarded.
258-
259-
Furthermore, if the content is an array or an object, the surrounding delimiters MUST be removed before serialisation. In other words, the outermost object or array is represented without the braces ("{}") or brackets ("[]") respectively, but this does not apply to inner objects or arrays.
260-
261-
For example, the two JSON values below are those of the fictitious "example" and "example1" hints, respectively:
262-
263-
~~~
264-
"The Example Value"
265-
1.2
266-
~~~
267-
268-
In a Link header, they would be serialised as:
269-
270-
~~~ http-message
271-
Link: </>; rel="sample"; example="The Example Value";
272-
example1=1.2
273-
~~~
274-
275-
A more complex, single value for "example":
276-
277-
~~~ json
278-
[
279-
"foo",
280-
-1.23,
281-
true,
282-
["charlie", "bennet"],
283-
{"cat": "thor"},
284-
false
285-
]
286-
~~~
287-
288-
would be serialised as:
289-
290-
~~~ http-message
291-
Link: </>; rel="sample"; example="\"foo\", -1.23, true,
292-
[\"charlie\", \"bennet\"], {"cat": \"thor\"}, false"
293-
~~~
294-
295-
296216

297217
# Acknowledgements
298218

0 commit comments

Comments
 (0)