-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathhttp-types.wit
59 lines (50 loc) · 1.14 KB
/
http-types.wit
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
/// The HTTP status code.
type http-status = u16
/// The HTTP body.
type body = list<u8>
/// The HTTP headers represented as a list of (name, value) pairs.
type headers = list<tuple<string, string>>
/// The HTTP parameter queries, represented as a list of (name, value) pairs.
type params = list<tuple<string, string>>
/// The HTTP URI of the current request.
type uri = string
/// The HTTP method.
enum method {
get,
post,
put,
delete,
patch,
head,
options,
}
/// An HTTP request.
record request {
method: method,
uri: uri,
headers: headers,
params: params,
body: option<body>,
}
/// An HTTP response.
record response {
status: http-status,
headers: option<headers>,
body: option<body>,
}
/// HTTP errors returned by the runtime.
variant http-error {
invalid-url(string),
timeout-error(string),
protocol-error(string),
status-error(u16),
unexpected-error(string)
}
/// HTTP errors returned by the runtime.
variant http-router-error {
invalid-url(string),
timeout-error(string),
protocol-error(string),
status-error(http-status),
unexpected-error(string)
}