forked from WebAssembly/wasi-http
/
incoming-handler.wit
26 lines (25 loc) · 1.26 KB
/
incoming-handler.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
// The `wasi:http/incoming-handler` interface is meant to be exported by
// components and called by the host in response to a new incoming HTTP
// response.
//
// NOTE: in Preview3, this interface will be merged with
// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface
// that takes a `request` parameter and returns a `response` result.
//
interface incoming-handler {
use http-types.{incoming-request, response-outparam}
// The `handle` function takes an outparam instead of returning its response
// so that the component may stream its response while streaming any other
// request or response bodies. The callee MUST write a response to the
// `response-out` and then finish the response before returning. The caller
// is expected to start streaming the response once `set-response-outparam`
// is called and finish streaming the response when `drop-response-outparam`
// is called. The `handle` function is then allowed to continue executing
// any post-response logic before returning. While this post-response
// execution is taken off the critical path, since there is no return value,
// there is no way to report its success or failure.
handle: func(
request: incoming-request,
response-out: response-outparam
)
}