1- use std:: { time:: Duration , sync:: atomic:: { AtomicUsize , Ordering } , env} ;
2- use actix_web:: { Responder , get, HttpServer , App , web, rt:: time:: sleep} ;
1+ use actix_web:: { get, rt:: time:: sleep, web, App , HttpServer , Responder } ;
2+ use std:: {
3+ env,
4+ sync:: atomic:: { AtomicUsize , Ordering } ,
5+ time:: Duration ,
6+ } ;
37
48const EXPLANATION : & str =
59"USAGE:
6- Delay server works by issuing a http GET request in the format:
7- http://localhost:8080/[delay in ms]/[UrlEncoded message]
10+ Delay server works by issuing an HTTP GET request in the format:
11+ http://localhost:8080/[delay in ms]/[URL-encoded message]
812
913If an argument is passed in when delayserver is started, that
10- argument will be used as the url instead of 'localhost'
14+ argument will be used as the URL instead of 'localhost'.
1115
12- On reception , it immieiately reports the following to the console:
16+ Upon receiving a request , it immediately reports the following to the console:
1317
1418{Message #} - {delay in ms}: {message}
1519
@@ -34,13 +38,10 @@ async fn main() -> std::io::Result<()> {
3438 let url = env:: args ( )
3539 . nth ( 1 )
3640 . unwrap_or_else ( || String :: from ( "localhost" ) ) ;
37-
41+
3842 println ! ( "{EXPLANATION}" ) ;
39- HttpServer :: new ( || {
40- App :: new ( )
41- . service ( delay)
42- } )
43- . bind ( ( url, 8080 ) ) ?
44- . run ( )
45- . await
43+ HttpServer :: new ( || App :: new ( ) . service ( delay) )
44+ . bind ( ( url, 8080 ) ) ?
45+ . run ( )
46+ . await
4647}
0 commit comments