@@ -6,31 +6,31 @@ use tide::body;
6
6
7
7
#[ derive( Serialize , Deserialize , Clone , Debug ) ]
8
8
struct Message {
9
- author : Option < String > ,
10
- contents : String ,
9
+ author : Option < String > ,
10
+ contents : String ,
11
11
}
12
12
13
13
async fn echo_string ( msg : String ) -> String {
14
- println ! ( "String: {}" , msg) ;
15
- format ! ( "{}" , msg)
14
+ println ! ( "String: {}" , msg) ;
15
+ format ! ( "{}" , msg)
16
16
}
17
17
18
18
async fn echo_vec ( msg : Vec < u8 > ) -> String {
19
- println ! ( "Vec<u8>: {:?}" , msg) ;
19
+ println ! ( "Vec<u8>: {:?}" , msg) ;
20
20
21
- String :: from_utf8 ( msg) . unwrap ( )
21
+ String :: from_utf8 ( msg) . unwrap ( )
22
22
}
23
23
24
24
async fn echo_json ( msg : body:: Json < Message > ) -> body:: Json < Message > {
25
- println ! ( "JSON: {:?}" , msg. 0 ) ;
25
+ println ! ( "JSON: {:?}" , msg. 0 ) ;
26
26
27
- msg
27
+ msg
28
28
}
29
29
30
30
fn main ( ) {
31
- let mut app = tide:: App :: new ( ( ) ) ;
32
- app. at ( "/echo/string" ) . post ( echo_string) ;
33
- app. at ( "/echo/vec" ) . post ( echo_vec) ;
34
- app. at ( "/echo/json" ) . post ( echo_json) ;
35
- app. serve ( "127.0.0.1:8000" ) ;
31
+ let mut app = tide:: App :: new ( ( ) ) ;
32
+ app. at ( "/echo/string" ) . post ( echo_string) ;
33
+ app. at ( "/echo/vec" ) . post ( echo_vec) ;
34
+ app. at ( "/echo/json" ) . post ( echo_json) ;
35
+ app. serve ( "127.0.0.1:8000" ) ;
36
36
}
0 commit comments