Skip to content

Commit d4acece

Browse files
committed
Caching and background processing
1 parent 6f07862 commit d4acece

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The server must respond with the following status codes, according to the situat
7676
| 200 OK | Request succeeded. Response included |
7777
| 201 Created | Resource created. URL to new resource in Location header |
7878
| 204 No Content | Request succeeded, but no response body |
79-
| 303 See other | The resource is in another location. See [Asynchronous processing](#asynchronous_processing). |
79+
| 303 See other | The resource is in another location. See [Asynchronous processing](#asynchronous-processing). |
8080
| 304 Not Modified | The response is not modified since the last call. Returned by the cache. |
8181
| 400 Bad Request | Could not parse request |
8282
| 401 Unauthorized | No authentication credentials provided or authentication failed |
@@ -440,13 +440,46 @@ Content-Type: application/json
440440

441441
If the server does not support selection as specified in the query parameter `fields`, it must return a `400 Bad Request` status code.
442442

443+
443444
### Caching
444445

445-
> TODO
446+
Server should generate a [ETag header](http://en.wikipedia.org/wiki/HTTP_ETag) containing a hash or checksum of the representation. This value should change whenever the output representation changes.
446447

447448
### Asynchronous processing
448449

449-
When a resource creation or update is asynchronously processed, the request should return a `202 Accepted` status code with a link in the `Content-Location` header.
450+
When a resource creation or update is asynchronously processed, the request should return a `202 Accepted` status code with a link in the `Content-Location` header which should redirect to the resource when the job processing is done.
451+
452+
453+
```HTTP
454+
POST /movies HTTP/1.1
455+
Accept: application/json
456+
Content-Type: application/json
457+
Host: api.example.com
458+
459+
{
460+
"movie": {
461+
"name": "Charlie the Unicorn",
462+
"source": "https://www.youtube.com/watch?v=CsGYh8AacgY"
463+
}
464+
}
465+
466+
HTTP/1.1 202 Accepted
467+
Content-Type: application/json
468+
Content-Location: https://api.example.com/movies/jobs/42
469+
470+
{}
471+
```
472+
473+
When the job process is done, the request of the url in the `Content-Location` header should return a `303 See other` status code with the created resource link in `Location` header.
474+
475+
```HTTP
476+
GET /movies/jobs/42 HTTP/1.1
477+
Accept: application/json
478+
479+
HTTP/1.1 303 See other
480+
Content-Type: application/json
481+
Location: https://api.example.com/movies/3
482+
```
450483

451484
### Sources
452485

0 commit comments

Comments
 (0)