-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.html
More file actions
executable file
·63 lines (61 loc) · 2.23 KB
/
Copy pathheaders.html
File metadata and controls
executable file
·63 lines (61 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<meta charset="UTF-8">
<title>Sail - Simple Api Interaction Language -Headers</title>
<meta name="description" content="Sail is a hypermedia language for APIs">
<meta name="keywords" content="Hypermedia,API,JSON,headers">
<link rel="stylesheet" type="text/css" href="resources/style.css">
</head>
<body>
<header>
<div class="header">
<a href="./index.html#headers"> Home </a>
</div>
</header>
<section class="summary">
<h2>Headers</h2>
<p>It is common to include headers as part of the API protocol. Lets say it is required to tack all request a user made. For this some APIs define a custom header where a transaction id is spefied for each request associated to the user. In this case the client must know wich header to send generating certain coupling. In Sail, a header section with pre set values can be specifiead in links and forms so the client doesn't need to handle them. <a href="./headers.html"> More </a></p>
<div class="siblings json">
<pre>
<span class="field">"#links"</span>: [
{
<span class="field">"href"</span>:<span class="string">"http://api.com/products/1/reviews"</span>,
<span class="field">"rel"</span>:<span class="string">"reviews"</span>,
<span class="field">"headers"</span>:{
<span class="field">"X-TID"</span>:<span class="string">"3d3424ed"</span>
}
}
]
</pre>
<pre>
GET http://api.com/products/1/reviews
X-TID:3d3424ed
</pre>
<div>
<div class="siblings json">
<pre>
<span class="field">"#forms"</span>: [
{
<span class="field">"id"</span>:<span class="string">"add"</span>,
<span class="field">"action"</span>:<span class="string">"http://api.com/products"</span>,
<span class="field">"method"</span>:<span class="string">"POST"</span>,
<span class="field">"headers"</span>:{
<span class="field">"X-TID"</span>:<span class="string">"3d3424ed"</span>
}
<span class="field">"inputs"</span>: [
...
]
}
]
</pre>
<pre>
POST http://api.com/products
X-TID:3d3424ed
{
...
}
</pre>
</div>
</section>
</body>
</html>