use hyper::upgrade::on

This commit is contained in:
Jun Kurihara 2023-12-15 15:36:00 +09:00
commit d85d7e6c39
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 18 additions and 16 deletions

View file

@ -32,11 +32,10 @@ pub enum HttpError {
#[error("Failed to upgrade connection: {0}")]
FailedToUpgrade(String),
#[error("Request does not have an upgrade extension")]
NoUpgradeExtensionInRequest,
#[error("Response does not have an upgrade extension")]
NoUpgradeExtensionInResponse,
// #[error("Request does not have an upgrade extension")]
// NoUpgradeExtensionInRequest,
// #[error("Response does not have an upgrade extension")]
// NoUpgradeExtensionInResponse,
#[error(transparent)]
Other(#[from] anyhow::Error),
}
@ -54,8 +53,8 @@ impl From<HttpError> for StatusCode {
HttpError::FailedToAddSetCookeInResponse(_) => StatusCode::INTERNAL_SERVER_ERROR,
HttpError::FailedToGenerateDownstreamResponse(_) => StatusCode::INTERNAL_SERVER_ERROR,
HttpError::FailedToUpgrade(_) => StatusCode::INTERNAL_SERVER_ERROR,
HttpError::NoUpgradeExtensionInRequest => StatusCode::BAD_REQUEST,
HttpError::NoUpgradeExtensionInResponse => StatusCode::BAD_GATEWAY,
// HttpError::NoUpgradeExtensionInRequest => StatusCode::BAD_REQUEST,
// HttpError::NoUpgradeExtensionInResponse => StatusCode::BAD_GATEWAY,
_ => StatusCode::INTERNAL_SERVER_ERROR,
}
}