pub async fn start<T>(
req: &HttpRequest,
target: String,
stream: T,
) -> Result<HttpResponse, Error>Expand description
start a websocket proxy
target should be a URL of the form ws://<host> or wss://<host>
see awc::Client::ws for more information
req and stream are exactly like the arguments to actix_web_actors::ws::start
#[get("/proxy/{port}")]
async fn proxy(
req: HttpRequest,
stream: web::Payload,
port: web::Path<u16>,
) -> Result<HttpResponse, Error> {
actix_ws_proxy::start(&req, format!("ws://127.0.0.1:{}", port), stream).await
}