13
13
// limitations under the License.
14
14
15
15
use proxy_wasm:: callout:: http:: HttpClient ;
16
- use proxy_wasm:: hostcalls;
17
16
use proxy_wasm:: callout:: promise:: Promise ;
17
+ use proxy_wasm:: hostcalls;
18
18
use proxy_wasm:: traits:: * ;
19
19
use proxy_wasm:: types:: * ;
20
20
use std:: time:: Duration ;
@@ -32,40 +32,40 @@ struct HttpParallelCall {
32
32
impl HttpContext for HttpParallelCall {
33
33
fn on_http_request_headers ( & mut self , _: usize , _: bool ) -> Action {
34
34
// "Hello, "
35
- let promise1 = self . client . dispatch (
36
- "httpbin" ,
37
- vec ! [
38
- ( ":method" , "GET" ) ,
39
- ( ":path" , "/base64/SGVsbG8sIA==" ) ,
40
- ( ":authority" , "httpbin.org" ) ,
41
- ] ,
42
- None ,
43
- vec ! [ ] ,
44
- Duration :: from_secs ( 1 ) ,
45
- ) ;
35
+ let promise1 = self
36
+ . client
37
+ . dispatch (
38
+ "httpbin" ,
39
+ vec ! [
40
+ ( ":method" , "GET" ) ,
41
+ ( ":path" , "/base64/SGVsbG8sIA==" ) ,
42
+ ( ":authority" , "httpbin.org" ) ,
43
+ ] ,
44
+ None ,
45
+ vec ! [ ] ,
46
+ Duration :: from_secs ( 1 ) ,
47
+ )
48
+ . then ( |( _, _, body_size, _) | get_http_call_response_body_string ( 0 , body_size) )
49
+ . then ( |body| body. unwrap_or_default ( ) ) ;
46
50
47
51
// "World!"
48
- let promise2 = self . client . dispatch (
49
- "httpbin" ,
50
- vec ! [
51
- ( ":method" , "GET" ) ,
52
- ( ":path" , "/base64/V29ybGQh" ) ,
53
- ( ":authority" , "httpbin.org" ) ,
54
- ] ,
55
- None ,
56
- vec ! [ ] ,
57
- Duration :: from_secs ( 1 ) ,
58
- ) ;
52
+ let promise2 = self
53
+ . client
54
+ . dispatch (
55
+ "httpbin" ,
56
+ vec ! [
57
+ ( ":method" , "GET" ) ,
58
+ ( ":path" , "/base64/V29ybGQh" ) ,
59
+ ( ":authority" , "httpbin.org" ) ,
60
+ ] ,
61
+ None ,
62
+ vec ! [ ] ,
63
+ Duration :: from_secs ( 1 ) ,
64
+ )
65
+ . then ( |( _, _, body_size, _) | get_http_call_response_body_string ( 0 , body_size) )
66
+ . then ( |body| body. unwrap_or_default ( ) ) ;
59
67
60
- Promise :: all_of ( vec ! [
61
- promise1
62
- . then( |( _, _, body_size, _) | get_http_call_response_body_string( 0 , body_size) )
63
- . then( |body| body. unwrap_or_default( ) ) ,
64
- promise2
65
- . then( |( _, _, body_size, _) | get_http_call_response_body_string( 0 , body_size) )
66
- . then( |body| body. unwrap_or_default( ) ) ,
67
- ] )
68
- . then ( |results| {
68
+ Promise :: all_of ( vec ! [ promise1, promise2] ) . then ( |results| {
69
69
send_http_response (
70
70
200 ,
71
71
vec ! [ ] ,
0 commit comments