pub trait Servable: Send + Sync {
// Required methods
fn head<'a>(
&'a self,
ctx: &'a RenderContext,
) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>;
fn render<'a>(
&'a self,
ctx: &'a RenderContext,
) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>;
}Expand description
Something that may be served over http. If implementing this trait, refer to sample implementations in redirect::Redirect, asset::StaticAsset and html::HtmlPage.
Required Methods§
Sourcefn head<'a>(
&'a self,
ctx: &'a RenderContext,
) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>
fn head<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<()>> + Send + Sync + 'a>>
Return the same response as Servable::render, but with an empty body.
This method is used to respond to HEAD requests.
Sourcefn render<'a>(
&'a self,
ctx: &'a RenderContext,
) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>
fn render<'a>( &'a self, ctx: &'a RenderContext, ) -> Pin<Box<dyn Future<Output = Rendered<RenderedBody>> + Send + Sync + 'a>>
Render this page. Must return the same metadata as Servable::head. Consider using crate::Rendered::with_body and Servable::head to implement this fn.
This method is used to respond to GET requests.