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