@@ -10,7 +10,7 @@ use tide::{
1010} ;
1111
1212use wasmtime:: { component:: * , Config , Engine , Store } ;
13- use wasmtime_wasi:: preview2:: { wasi , Table , WasiCtx , WasiCtxBuilder , WasiView } ;
13+ use wasmtime_wasi:: preview2:: { command , Table , WasiCtx , WasiCtxBuilder , WasiView } ;
1414
1515use exports:: example:: service:: * ;
1616
@@ -118,33 +118,26 @@ impl ServerApp {
118118 let body = req. body_bytes ( ) . await ?;
119119 let headers = req
120120 . iter ( )
121- . map ( |( n, v) | ( n. as_str ( ) . as_bytes ( ) , v. as_str ( ) . as_bytes ( ) ) )
121+ . map ( |( n, v) | {
122+ (
123+ n. as_str ( ) . as_bytes ( ) . to_vec ( ) ,
124+ v. as_str ( ) . as_bytes ( ) . to_vec ( ) ,
125+ )
126+ } )
122127 . collect :: < Vec < _ > > ( ) ;
123128
124129 // Create a new store for the request
125130 let state = req. state ( ) ;
126131 let mut linker = Linker :: new ( & state. engine ) ;
127- wasi:: filesystem:: filesystem:: add_to_linker ( & mut linker, |x| x) ?;
128- wasi:: io:: streams:: add_to_linker ( & mut linker, |x| x) ?;
129- wasi:: cli_base:: environment:: add_to_linker ( & mut linker, |x| x) ?;
130- wasi:: cli_base:: preopens:: add_to_linker ( & mut linker, |x| x) ?;
131- wasi:: cli_base:: exit:: add_to_linker ( & mut linker, |x| x) ?;
132- wasi:: cli_base:: stdin:: add_to_linker ( & mut linker, |x| x) ?;
133- wasi:: cli_base:: stdout:: add_to_linker ( & mut linker, |x| x) ?;
134- wasi:: cli_base:: stderr:: add_to_linker ( & mut linker, |x| x) ?;
132+ command:: add_to_linker ( & mut linker) ?;
135133
136134 let wasi_view = ServerWasiView :: new ( ) ?;
137135 let mut store = Store :: new ( & state. engine , wasi_view) ;
138- let ( service, _) = Service :: instantiate_async ( & mut store, & state. component , & linker) . await ?;
136+ let ( service, _) =
137+ Service :: instantiate_async ( & mut store, & state. component , & linker) . await ?;
139138 service
140139 . example_service_handler ( )
141- . call_execute (
142- & mut store,
143- handler:: Request {
144- headers : & headers,
145- body : & body,
146- } ,
147- )
140+ . call_execute ( & mut store, & handler:: Request { headers, body } )
148141 . await ?
149142 . map ( TryInto :: try_into)
150143 . map_err ( handler:: Error :: into_tide) ?
0 commit comments