Commit 185a3439 authored by paul121's avatar paul121 Committed by e0ipso
Browse files

Issue #3194297 by paul121, e0ipso, kaszarobert: Document the JSON response type

parent cf187160
......@@ -195,11 +195,19 @@ been generated, the server **MUST** give a single response to the master
request containing the responses to all subrequests.
The response **MUST** use the 207 response code for multiple status, since each
partial response will specify the status for their requests. In addition to that
the response to the master request will use the `multipart/related` MIME type as
specified in [RFC 2387](https://tools.ietf.org/html/rfc2387).
partial response will specify the status for their requests.
The response contents to the blueprint above could look like:
## HTML Response
The default response format is HTML.
HTML responses will use the `multipart/related` MIME type as specified in
[RFC 2387](https://tools.ietf.org/html/rfc2387):
```http
Content-Type: multipart/related; boundary="e43889"; type=application/json
```
A response to the blueprint above could look like:
```http
--e43889
......@@ -207,14 +215,14 @@ Cache-Control: no-cache
Content-Id: <req-1>
Content-Type: application/json
Status: 200
{"attrs": {"name": "Foo restaurant"}, "rels": {"menu": {"id": "1234"}}}
--e43889
Cache-Control: no-cache
Content-Id: <req-2>
Content-Type: application/json
Status: 200
{"mainCourse": {"id": "meat-pie"}, "desert": {"id": "9876"}}
--e43889
Cache-Control: no-cache
......@@ -222,14 +230,71 @@ Content-Id: <req-3>
Content-Type: application/vnd.api+json
Status: 200
{"ingredients": ["meat", "crust"]}
--e43889--
```
Whereas the response HTTP header for the content type specifies the delimiter,
among other information, as:
## JSON Response
A JSON response can be requested by specifying the JSON format with
`?_format=json`.
```http
Conten-Type: multipart/related; boundary="e43889", type=application/json
The response will be a JSON object containing each subrequest response keyed by
the specified `requestId`.
A response to the blueprint above could look like:
```json
{
"req-1": {
"headers": {
"cache-control": [
"no-cache"
],
"content-id": [
"<req-1>"
],
"content-type": [
"application/json"
],
"status": [
200
]
},
"body": "{\"attrs\": {\"name\": \"Foo restaurant\"}, \"rels\": {\"menu\":{\"id\":\"1234\"}}}"
},
"req-2": {
"headers": {
"cache-control": [
"no-cache"
],
"content-id": [
"<req-2>"
],
"content-type": [
"application/json"
],
"status": [
200
]
},
"body": "{\"mainCourse\": {\"id\": \"meat-pie\"}, \"desert\": {\"id\":\"9876\"}}"
},
"req-3": {
"headers": {
"cache-control": [
"no-cache"
],
"content-id": [
"<req-3>"
],
"content-type": [
"application/vnd.api+json"
],
"status": [
200
]
},
"body": "{\"ingredients\": [\"meat\", \"crust\"]}"
}
}
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment