1 use test_programs::proxy;
2 use test_programs::wasi::http::types::{
3     Fields, IncomingRequest, OutgoingResponse, ResponseOutparam, Scheme,
4 };
5 
6 struct T;
7 
8 proxy::export!(T);
9 
10 impl proxy::exports::wasi::http::incoming_handler::Guest for T {
handle(request: IncomingRequest, outparam: ResponseOutparam)11     fn handle(request: IncomingRequest, outparam: ResponseOutparam) {
12         let authority = request.authority();
13         let scheme = request.scheme();
14 
15         assert_eq!(authority.as_deref(), Some("localhost"));
16         assert!(
17             matches!(scheme, Some(Scheme::Http)),
18             "bad scheme: {scheme:?}",
19         );
20 
21         let resp = OutgoingResponse::new(Fields::new());
22         ResponseOutparam::set(outparam, Ok(resp));
23     }
24 }
25 
main()26 fn main() {}
27