| 1 |
use wasip2::http::types::{ |
| 2 |
Fields, IncomingRequest, OutgoingBody, OutgoingResponse, ResponseOutparam, |
| 3 |
}; |
| 4 |
|
| 5 |
wasip2::http::proxy::export!(Example); |
| 6 |
|
| 7 |
struct Example; |
| 8 |
|
| 9 |
impl wasip2::exports::http::incoming_handler::Guest for Example { |
| 10 |
fn handle(_request: IncomingRequest, response_out: ResponseOutparam) { |
| 11 |
let resp = OutgoingResponse::new(Fields::new()); |
| 12 |
let body = resp.body().unwrap(); |
| 13 |
|
| 14 |
ResponseOutparam::set(response_out, Ok(resp)); |
| 15 |
|
| 16 |
let out = body.write().unwrap(); |
| 17 |
out.blocking_write_and_flush(b"Hello, WASI!").unwrap(); |
| 18 |
drop(out); |
| 19 |
|
| 20 |
OutgoingBody::finish(body, None).unwrap(); |
| 21 |
} |
| 22 |
} |