feat: container

This commit is contained in:
2022-07-23 16:54:36 +08:00
parent b908736c1c
commit 842c5b4579
3 changed files with 33 additions and 1 deletions

View File

@@ -29,6 +29,10 @@ impl container::Container for MyContainer {
println!("+ fetch: {}, time cost: {}ms", params, e.as_millis());
result
}
fn log(&mut self, level: &str, message: &str) {
println!("[{}] {}", level, message);
}
}
wit_bindgen_wasmtime::import!("../exports.wit");
@@ -45,13 +49,17 @@ fn main() -> Result<()> {
let eval_t1 = SystemTime::now();
let a = exports.eval_javascript(&mut store, r##"
function hi(name) { return "hi: " + name; }
console.log('hello', 1, true);
let a = [];
// a.push(console);
console.log('query: ' + 'print_request.action');
a.push(fetch('https://hatter.ink/util/print_request.action', {
headers: {
'Test-Header': 'this is a test header'
}
}));
// a.push(fetch('https://hatter.ink/ip.action'));
console.log('query: ' + 'ip.jsonp');
a.push(fetch('https://hatter.ink/ip/ip.jsonp'));
// a.push(fetch('https://hatter.ink/ip2.action'));
a.push({