Function async_tungstenite::gio::connect_async

source ยท
pub async fn connect_async<R>(
    request: R,
) -> Result<(WebSocketStream<ConnectStream>, Response), Error>
Expand description

Connect to a given URL.

Accepts any request that implements IntoClientRequest, which is often just &str, but can be a variety of types such as httparse::Request or tungstenite::http::Request for more complex uses.


use tungstenite::http::{Method, Request};
use async_tungstenite::gio::connect_async;

let mut request = "wss://api.example.com".into_client_request().unwrap();
request.headers_mut().insert("api-key", "42".parse().unwrap());

let (stream, response) = connect_async(request).await.unwrap();