Crates.io | ehttp |
lib.rs | ehttp |
version | 0.5.0 |
source | src |
created_at | 2021-09-03 18:45:27.623045 |
updated_at | 2024-02-16 09:10:06.414258 |
description | Minimal HTTP client for both native and WASM |
homepage | https://github.com/emilk/ehttp |
repository | https://github.com/emilk/ehttp |
max_upload_size | |
id | 446588 |
size | 40,514 |
If you want to do HTTP requests and are targeting both native and web (WASM), then this is the crate for you!
You can try the web demo here (works in any browser with WASM and WebGL support). Uses eframe
.
let request = ehttp::Request::get("https://www.example.com");
ehttp::fetch(request, move |result: ehttp::Result<ehttp::Response>| {
println!("Status code: {:?}", result.unwrap().status);
});
The given callback is called when the request is completed. You can communicate the results back to the main thread using something like:
std::sync::mpsc::channel
).Arc<Mutex<_>>
poll_promise::Promise
eventuals::Eventual
tokio::sync::watch::channel
There is also a streaming version under ehttp::fetch::streaming
, hidden behind the streaming
feature flag.