use crate::health::endpoint_500s::EndpointHealth;
use crate::server::RawBody;
use crate::service::endpoint_metrics::EndpointMetrics;
use crate::service::handler::BodyWriteAborted;
use async_trait::async_trait;
use bytes::Bytes;
use conjure_http::server::EndpointMetadata;
use futures_util::future::BoxFuture;
use http::{Request, Response};
use http_body_util::combinators::BoxBody;
use std::sync::Arc;
pub mod conjure;
pub mod errors;
pub mod extended_path;
#[async_trait]
pub trait WitchcraftEndpoint: EndpointMetadata {
fn metrics(&self) -> Option<&EndpointMetrics>;
fn health(&self) -> Option<&Arc<EndpointHealth>>;
async fn handle(&self, req: Request<RawBody>) -> Response<BoxBody<Bytes, BodyWriteAborted>>;
}
impl<T> WitchcraftEndpoint for Box<T>
where
T: ?Sized + WitchcraftEndpoint,
{
fn metrics(&self) -> Option<&EndpointMetrics> {
(**self).metrics()
}
fn health(&self) -> Option<&Arc<EndpointHealth>> {
(**self).health()
}
fn handle<'life0, 'async_trait>(
&'life0 self,
req: Request<RawBody>,
) -> BoxFuture<'life0, Response<BoxBody<Bytes, BodyWriteAborted>>>
where
'life0: 'async_trait,
Self: 'async_trait,
{
(**self).handle(req)
}
}