File tree Expand file tree Collapse file tree 4 files changed +53
-3
lines changed Expand file tree Collapse file tree 4 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -32,4 +32,6 @@ actix-utils = "1.0.3"
32
32
awc = " *" # actix_web_client
33
33
actix-codec = " *"
34
34
futures = " *"
35
- toml = " *"
35
+ toml = " *"
36
+ hyper = " *"
37
+ hyper-tls = " *"
Original file line number Diff line number Diff line change
1
+ use bytes:: buf:: BufExt ;
2
+
3
+ #[ cfg( debug_assertions) ]
4
+ const URL : & str = "https://jsonplaceholder.typicode.com/users/1" ;
5
+
6
+ #[ tokio:: test( core_threads = 1 ) ]
7
+ async fn simple_http_request ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
8
+ let res = hyper:: Client :: new ( )
9
+ . get ( URL . replace ( "https" , "http" ) . parse ( ) ?)
10
+ . await ?;
11
+ let res_body = hyper:: body:: aggregate ( res) . await ?;
12
+ let res_json: serde_json:: Value = serde_json:: from_reader ( res_body. reader ( ) ) ?;
13
+ dbg ! ( res_json) ;
14
+ Ok ( ( ) )
15
+ }
16
+
17
+ #[ tokio:: test( core_threads = 1 ) ]
18
+ async fn hyper_https_request ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
19
+ let https_client =
20
+ hyper:: Client :: builder ( ) . build :: < _ , hyper:: Body > ( hyper_tls:: HttpsConnector :: new ( ) ) ;
21
+ let res = https_client. get ( URL . parse ( ) ?) . await ?;
22
+ let res_json: serde_json:: Value =
23
+ serde_json:: from_reader ( hyper:: body:: aggregate ( res) . await ?. reader ( ) ) ?;
24
+ dbg ! ( res_json) ;
25
+ Ok ( ( ) )
26
+ }
27
+
28
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ macro_rules! my_dbg {
2
+ ( $expr: expr) => {
3
+ println!(
4
+ "[{}:{}] {} = {:#?}" ,
5
+ file!( ) ,
6
+ line!( ) ,
7
+ stringify!( $expr) ,
8
+ $expr
9
+ ) ;
10
+ } ;
11
+ }
12
+
13
+ fn main ( ) {
14
+ my_dbg ! ( 1 + 1 ) ;
15
+ dbg ! ( 1 + 1 ) ;
16
+ my_dbg ! ( ( 1 , 2 ) ) ;
17
+ dbg ! ( ( 1 , 2 ) ) ;
18
+ dbg ! ( 1 , 2 , 3 ) ;
19
+ // TODO my_dbg!(1, 2, 3);
20
+ }
Original file line number Diff line number Diff line change @@ -61,13 +61,13 @@ struct MySQLConfig {
61
61
#[ derive( Deserialize ) ]
62
62
struct DbName {
63
63
production : String ,
64
- test : Option < String >
64
+ test : Option < String > ,
65
65
}
66
66
67
67
#[ derive( Deserialize ) ]
68
68
struct RedisClusterConfig {
69
69
url : String ,
70
- password : Option < String >
70
+ password : Option < String > ,
71
71
}
72
72
73
73
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
You can’t perform that action at this time.
0 commit comments