@@ -2,16 +2,19 @@ mod client;
2
2
mod server;
3
3
4
4
use anyhow:: { Context , Result } ;
5
- use http_body_util:: Collected ;
5
+ use http_body_util:: { combinators :: BoxBody , Collected } ;
6
6
use hyper:: body:: Bytes ;
7
7
use wasmtime:: {
8
8
component:: { Component , Linker , ResourceTable } ,
9
9
Config , Engine , Store ,
10
10
} ;
11
11
use wasmtime_wasi:: { bindings:: Command , DirPerms , FilePerms , WasiCtx , WasiCtxBuilder , WasiView } ;
12
12
use wasmtime_wasi_http:: {
13
- bindings:: http:: types:: ErrorCode , body:: HyperIncomingBody , proxy:: Proxy , WasiHttpCtx ,
14
- WasiHttpView ,
13
+ bindings:: {
14
+ http:: types:: { ErrorCode , Scheme } ,
15
+ Proxy ,
16
+ } ,
17
+ WasiHttpCtx , WasiHttpView ,
15
18
} ;
16
19
17
20
struct Ctx {
@@ -60,20 +63,20 @@ fn new_component(component_filename: &str) -> Result<(Store<Ctx>, Component, Lin
60
63
let store = Store :: new ( & engine, ctx) ;
61
64
let mut linker = Linker :: new ( & engine) ;
62
65
wasmtime_wasi:: add_to_linker_async ( & mut linker) ?;
63
- wasmtime_wasi_http:: proxy :: add_only_http_to_linker ( & mut linker) ?;
66
+ wasmtime_wasi_http:: add_only_http_to_linker_async ( & mut linker) ?;
64
67
Ok ( ( store, component, linker) )
65
68
}
66
69
67
70
// ref: https://github.com/bytecodealliance/wasmtime/blob/af59c4d568d487b7efbb49d7d31a861e7c3933a6/crates/wasi-http/tests/all/main.rs#L129
68
71
pub async fn run_wasi_http (
69
72
component_filename : & str ,
70
- req : hyper:: Request < HyperIncomingBody > ,
73
+ req : hyper:: Request < BoxBody < Bytes , hyper :: Error > > ,
71
74
) -> Result < Result < hyper:: Response < Collected < Bytes > > , ErrorCode > > {
72
75
let ( mut store, component, linker) = new_component ( component_filename) ?;
73
76
74
- let ( proxy, _ ) = Proxy :: instantiate_async ( & mut store, & component, & linker) . await ?;
77
+ let proxy = Proxy :: instantiate_async ( & mut store, & component, & linker) . await ?;
75
78
76
- let req = store. data_mut ( ) . new_incoming_request ( req) ?;
79
+ let req = store. data_mut ( ) . new_incoming_request ( Scheme :: Http , req) ?;
77
80
78
81
let ( sender, receiver) = tokio:: sync:: oneshot:: channel ( ) ;
79
82
let out = store. data_mut ( ) . new_response_outparam ( sender) ?;
@@ -111,7 +114,7 @@ pub async fn run_wasi_http(
111
114
pub async fn run_wasi ( component_filename : & str ) -> Result < ( ) > {
112
115
let ( mut store, component, linker) = new_component ( component_filename) ?;
113
116
114
- let ( command, _ ) = Command :: instantiate_async ( & mut store, & component, & linker) . await ?;
117
+ let command = Command :: instantiate_async ( & mut store, & component, & linker) . await ?;
115
118
command
116
119
. wasi_cli_run ( )
117
120
. call_run ( & mut store)
0 commit comments