8000 GitHub - shenek/reqwasm: HTTP requests library for WASM Apps
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

shenek/reqwasm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reqwasm

crates.io docs.rs licence

HTTP requests library for WASM Apps. It provides idiomatic Rust bindings for the web_sys fetch and WebSocket API

Examples

HTTP

let resp = Request::get("/path")
    .send()
    .await
    .unwrap();
assert_eq!(resp.status(), 200);

WebSocket

let ws = WebSocket::open("wss://echo.websocket.org").unwrap();

let (mut sender, mut receiver) = (ws.sender, ws.receiver);

spawn_local(async move {
    while let Some(m) = receiver.next().await {
        match m {
            Ok(Message::Text(m)) => console_log!("message", m),
            Ok(Message::Bytes(m)) => console_log!("message", format!("{:?}", m)),
            Err(e) => {}
        }
    }
});

spawn_local(async move {
    sender.send(Message::Text("test".to_string())).await.unwrap();
})

Contributions

Your PRs and Issues are welcome. Note that all the contribution submitted by you, shall be licensed as MIT or APACHE 2.0 at your choice, without any additional terms or conditions.

About

HTTP requests library for WASM Apps

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.md
MIT
LICENSE-MIT.md

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%
0