Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

WsClient::from_http_url

Construct a WsClient from an HTTP URL, rewriting the scheme.

Signature

pub fn from_http_url(url: impl Into<String>) -> Result<Self, anyhow::Error>;

Example

use {anyhow::Result, dango_sdk::WsClient};
 
fn main() -> Result<()> {
    // https:// -> wss://
    let prod = WsClient::from_http_url("https://api-mainnet.dango.zone/graphql")?;
    // http://  -> ws://
    let dev  = WsClient::from_http_url("http://localhost:8080/graphql")?;
    let _ = (prod, dev);
    Ok(())
}

Parameters

urlimpl Into<String>. An http://, https://, ws://, or wss:// URL.

Returns

WsClient — same as new, but with HTTP schemes rewritten.

Notes

  • http://ws://, https://wss://. WebSocket schemes pass through unchanged.
  • Any other scheme errors with Invalid URL scheme: ….

See also

  • new — accept WebSocket schemes directly.