1 use test_programs::proxy;
2 use test_programs::wasi::{
3     config::store,
4     http::types::{Fields, IncomingRequest, OutgoingBody, OutgoingResponse, ResponseOutparam},
5 };
6 
7 struct T;
8 
9 proxy::export!(T);
10 
11 impl proxy::exports::wasi::http::incoming_handler::Guest for T {
handle(_: IncomingRequest, outparam: ResponseOutparam)12     fn handle(_: IncomingRequest, outparam: ResponseOutparam) {
13         let fields = Fields::new();
14         let resp = OutgoingResponse::new(fields);
15         let body = resp.body().expect("outgoing response");
16 
17         ResponseOutparam::set(outparam, Ok(resp));
18 
19         let out = body.write().expect("outgoing stream");
20         let config = store::get("hello").unwrap().unwrap();
21         out.blocking_write_and_flush(config.as_bytes())
22             .expect("writing response");
23 
24         drop(out);
25         OutgoingBody::finish(body, None).expect("outgoing-body.finish");
26     }
27 }
28 
main()29 fn main() {}
30