| 1 |
package example:[email protected]; |
| 2 |
|
| 3 |
interface types { |
| 4 |
resource request { |
| 5 |
constructor(headers: list<tuple<list<u8>, list<u8>>>, body: list<u8>); |
| 6 |
headers: func() -> list<tuple<list<u8>, list<u8>>>; |
| 7 |
body: func() -> list<u8>; |
| 8 |
} |
| 9 |
|
| 10 |
resource response { |
| 11 |
constructor(headers: list<tuple<list<u8>, list<u8>>>, body: list<u8>); |
| 12 |
headers: func() -> list<tuple<list<u8>, list<u8>>>; |
| 13 |
body: func() -> list<u8>; |
| 14 |
} |
| 15 |
|
| 16 |
enum error { |
| 17 |
bad-request, |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
interface handler { |
| 22 |
use types.{request, response, error}; |
| 23 |
|
| 24 |
execute: func(req: request) -> result<response, error>; |
| 25 |
} |
| 26 |
|
| 27 |
interface logging { |
| 28 |
resource logger { |
| 29 |
log: func(message: string); |
| 30 |
} |
| 31 |
|
| 32 |
get-logger: func() -> logger; |
| 33 |
} |
| 34 |
|
| 35 |
world service { |
| 36 |
import logging; |
| 37 |
export handler; |
| 38 |
} |
| 39 |
|
| 40 |
world middleware { |
| 41 |
import logging; |
| 42 |
import handler; |
| 43 |
export handler; |
| 44 |
} |