expose close reasons

This commit is contained in:
Toshit Chawda 2024-08-02 23:01:47 -07:00
parent 8cbab94955
commit 569789c2a0
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
9 changed files with 294 additions and 74 deletions

View file

@ -30,6 +30,7 @@ use wasm_streams::ReadableStream;
use web_sys::ResponseInit;
#[cfg(feature = "full")]
use websocket::EpoxyWebSocket;
use wisp_mux::CloseReason;
#[cfg(feature = "full")]
use wisp_mux::StreamType;
@ -50,6 +51,8 @@ pub enum EpoxyError {
InvalidDnsName(#[from] futures_rustls::rustls::pki_types::InvalidDnsNameError),
#[error("Wisp: {0:?} ({0})")]
Wisp(#[from] wisp_mux::WispError),
#[error("Wisp server closed: {0}")]
WispCloseReason(wisp_mux::CloseReason),
#[error("IO: {0:?} ({0})")]
Io(#[from] std::io::Error),
#[error("HTTP: {0:?} ({0})")]
@ -61,9 +64,6 @@ pub enum EpoxyError {
#[error("HTTP ToStr: {0:?} ({0})")]
ToStr(#[from] http::header::ToStrError),
#[cfg(feature = "full")]
#[error("Getrandom: {0:?} ({0})")]
GetRandom(#[from] getrandom::Error),
#[cfg(feature = "full")]
#[error("Fastwebsockets: {0:?} ({0})")]
FastWebSockets(#[from] fastwebsockets::WebSocketError),
@ -135,6 +135,12 @@ impl From<InvalidMethod> for EpoxyError {
}
}
impl From<CloseReason> for EpoxyError {
fn from(value: CloseReason) -> Self {
EpoxyError::WispCloseReason(value)
}
}
#[derive(Debug)]
enum EpoxyResponse {
Success(Response<Incoming>),