1
1
use wstd:: http:: body:: { BodyForthcoming , IncomingBody , OutgoingBody } ;
2
2
use wstd:: http:: server:: { Finished , Responder } ;
3
- use wstd:: http:: { IntoBody , Request , Response } ;
3
+ use wstd:: http:: { IntoBody , Request , Response , StatusCode } ;
4
4
use wstd:: io:: { copy, empty, AsyncWrite } ;
5
5
use wstd:: time:: { Duration , Instant } ;
6
6
@@ -13,7 +13,8 @@ async fn main(request: Request<IncomingBody>, responder: Responder) -> Finished
13
13
"/echo-trailers" => http_echo_trailers ( request, responder) . await ,
14
14
"/fail" => http_fail ( request, responder) . await ,
15
15
"/bigfail" => http_bigfail ( request, responder) . await ,
16
- "/" | _ => http_home ( request, responder) . await ,
16
+ "/" => http_home ( request, responder) . await ,
17
+ _ => http_not_found ( request, responder) . await ,
17
18
}
18
19
}
19
20
@@ -83,3 +84,11 @@ async fn http_echo_trailers(request: Request<IncomingBody>, responder: Responder
83
84
} ;
84
85
Finished :: finish ( body, result, trailers)
85
86
}
87
+
88
+ async fn http_not_found ( _request : Request < IncomingBody > , responder : Responder ) -> Finished {
89
+ let response = Response :: builder ( )
90
+ . status ( StatusCode :: NOT_FOUND )
91
+ . body ( empty ( ) )
92
+ . unwrap ( ) ;
93
+ responder. respond ( response) . await
94
+ }
0 commit comments