chore: change mod name
This commit is contained in:
parent
8f77ce9447
commit
f020ece60d
12 changed files with 4 additions and 4 deletions
|
|
@ -1,60 +0,0 @@
|
|||
use http::StatusCode;
|
||||
use thiserror::Error;
|
||||
|
||||
/// HTTP result type, T is typically a hyper::Response
|
||||
/// HttpError is used to generate a synthetic error response
|
||||
pub(crate) type HttpResult<T> = std::result::Result<T, HttpError>;
|
||||
|
||||
/// Describes things that can go wrong in the forwarder
|
||||
#[derive(Debug, Error)]
|
||||
pub enum HttpError {
|
||||
#[error("No host is give nin request header")]
|
||||
NoHostInRequestHeader,
|
||||
#[error("Invalid host in request header")]
|
||||
InvalidHostInRequestHeader,
|
||||
#[error("SNI and Host header mismatch")]
|
||||
SniHostInconsistency,
|
||||
#[error("No matching backend app")]
|
||||
NoMatchingBackendApp,
|
||||
#[error("Failed to redirect: {0}")]
|
||||
FailedToRedirect(String),
|
||||
#[error("No upstream candidates")]
|
||||
NoUpstreamCandidates,
|
||||
#[error("Failed to generate upstream request: {0}")]
|
||||
FailedToGenerateUpstreamRequest(String),
|
||||
|
||||
#[error("Failed to add set-cookie header in response")]
|
||||
FailedToAddSetCookeInResponse,
|
||||
#[error("Failed to generated downstream response: {0}")]
|
||||
FailedToGenerateDownstreamResponse(String),
|
||||
|
||||
#[error("Failed to upgrade connection")]
|
||||
FailedToUpgrade,
|
||||
#[error("Request does not have an upgrade extension")]
|
||||
NoUpgradeExtensionInRequest,
|
||||
#[error("Response does not have an upgrade extension")]
|
||||
NoUpgradeExtensionInResponse,
|
||||
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
impl From<HttpError> for StatusCode {
|
||||
fn from(e: HttpError) -> StatusCode {
|
||||
match e {
|
||||
HttpError::NoHostInRequestHeader => StatusCode::BAD_REQUEST,
|
||||
HttpError::InvalidHostInRequestHeader => StatusCode::BAD_REQUEST,
|
||||
HttpError::SniHostInconsistency => StatusCode::MISDIRECTED_REQUEST,
|
||||
HttpError::NoMatchingBackendApp => StatusCode::SERVICE_UNAVAILABLE,
|
||||
HttpError::FailedToRedirect(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
HttpError::NoUpstreamCandidates => StatusCode::NOT_FOUND,
|
||||
HttpError::FailedToGenerateUpstreamRequest(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
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,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue