Crates.io | actix-ws-proxy |
lib.rs | actix-ws-proxy |
version | 0.1.2 |
source | src |
created_at | 2023-12-30 19:20:26.97382 |
updated_at | 2023-12-30 19:24:00.457542 |
description | A websocket proxy for actix_web |
homepage | |
repository | https://git.sr.ht/~liz/actix-ws-proxy |
max_upload_size | |
id | 1084362 |
size | 11,190 |
A companion to actix-proxy that handles websockets.
use actix_web::{Error, get, HttpRequest, HttpResponse, web};
#[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
}
Any errors will result in a disconnect on both sides with the error message as the reason.