1- use url:: Url ;
21pub use wasi:: http:: types:: {
32 Fields , IncomingRequest , OutgoingBody , OutgoingResponse , ResponseOutparam ,
43} ;
@@ -8,16 +7,12 @@ wasi::http::proxy::export!(Component);
87
98impl wasi:: exports:: http:: incoming_handler:: Guest for Component {
109 fn handle ( req : IncomingRequest , outparam : ResponseOutparam ) {
11- let url = req. path_with_query ( ) . unwrap ( ) ;
12- let url = Url :: parse ( & url) . expect ( "could not parse the URL" ) ;
13- http_home ( req, outparam) ;
14- // dbg!(&url);
15- // match url.path() {
16- // "/wait" => http_wait(req, outparam),
17- // // "/echo" => {} // TODO
18- // // "/host" => {} // TODO
19- // "/" | _ => http_home(req, outparam),
20- // }
10+ match req. path_with_query ( ) . unwrap ( ) . as_str ( ) {
11+ "/wait" => http_wait ( req, outparam) ,
12+ // "/echo" => {} // TODO
13+ // "/host" => {} // TODO
14+ "/" | _ => http_home ( req, outparam) ,
15+ }
2116 }
2217}
2318
@@ -56,7 +51,7 @@ fn http_wait(_req: IncomingRequest, outparam: ResponseOutparam) {
5651 ResponseOutparam :: set ( outparam, Ok ( res) ) ;
5752
5853 let out = body. write ( ) . expect ( "outgoing stream" ) ;
59- let msg = format ! ( "slept for {elapsed} millis" ) ;
54+ let msg = format ! ( "slept for {elapsed} millis\n " ) ;
6055 out. blocking_write_and_flush ( msg. as_bytes ( ) )
6156 . expect ( "writing response" ) ;
6257
0 commit comments