1 use test_programs::p3::wasi::http::types::{ErrorCode, Fields, Request, Response};
2 use test_programs::p3::{service, wit_future, wit_stream};
3 
4 struct T;
5 
6 service::export!(T);
7 
8 impl service::exports::wasi::http::handler::Guest for T {
handle(_request: Request) -> Result<Response, ErrorCode>9     async fn handle(_request: Request) -> Result<Response, ErrorCode> {
10         let (mut body_tx, body_rx) = wit_stream::new();
11         let (body_result_tx, body_result_rx) = wit_future::new(|| Ok(None));
12         let (response, _future_result) =
13             Response::new(Fields::new(), Some(body_rx), body_result_rx);
14         drop(body_result_tx);
15 
16         wit_bindgen::spawn(async move {
17             let remaining = body_tx.write_all(b"Hello, WASI!".to_vec()).await;
18             assert!(remaining.is_empty());
19         });
20         Ok(response)
21     }
22 }
23 
main()24 fn main() {
25     unreachable!()
26 }
27