-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathhttp-server.wit
29 lines (21 loc) · 1010 Bytes
/
http-server.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
use { uri, http-status, http-router-error } from http-types
resource router {
/// create a new HTTP router
static new: func() -> expected<router, http-router-error>
/// create a new HTTP router
static new-with-base: func(base: uri) -> expected<router, http-router-error>
/// register a HTTP GET route
get: func(route: string, handler: string) -> expected<router, http-router-error>
/// register a HTTP PUT route
put: func(route: string, handler: string) -> expected<router, http-router-error>
/// register a HTTP POST route
post: func(route: string, handler: string) -> expected<router, http-router-error>
/// register a HTTP DELETE route
delete: func(route: string, handler: string) -> expected<router, http-router-error>
}
resource server {
/// create a new HTTP server and serve the given router
static serve: func(address: string, router: router) -> expected<server, http-router-error> // non-blocking
/// stop the server
stop: func() -> expected<unit, http-router-error>
}