use http::request::Parts;
use thiserror::Error;
use crate::{body::BoxBody, response::IntoResponse};
use super::{internal_server_error, FromParts};
#[non_exhaustive]
#[derive(Debug, Error)]
#[error(
"`ConnectInfo` is not present in the `http::Request` extensions - consider using `aws_smithy_http_server::routing::IntoMakeServiceWithConnectInfo`"
)]
pub struct MissingConnectInfo;
impl<Protocol> IntoResponse<Protocol> for MissingConnectInfo {
fn into_response(self) -> http::Response<BoxBody> {
internal_server_error()
}
}
#[derive(Clone, Debug)]
pub struct ConnectInfo<T>(
).
pub T,
);
impl<P, T> FromParts<P> for ConnectInfo<T>
where
T: Send + Sync + 'static,
{
type Rejection = MissingConnectInfo;
fn from_parts(parts: &mut Parts) -> Result<Self, Self::Rejection> {
parts.extensions.remove().ok_or(MissingConnectInfo)
}
}