[−][src]Function reign_view::render
pub fn render<D: Display>(view: D, status: u16) -> Result<Response<Body>, Error>
Renders a view for reign_router handler.
The response is sent with content-type set as text/html
.
Examples
use reign::{ view::render, router::{HandleFuture, Request, futures::FutureExt}, }; struct CustomView<'a> { msg: &'a str } impl Display for CustomView<'_> { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "<h1>{}</h1>", self.msg) } } fn handler(req: &mut Request) -> HandleFuture { async move { Ok(render(CustomView { msg: "Hello Reign!" }, 200)?) }.boxed() }