zon_util 0.0.1

part of a new WIP, very incomplete async http service stack
Documentation
use http::{header, HeaderValue};
use zon_core::{Body, IntoResponse, Response};

mod redirect;

pub use redirect::Redirect;

/// An HTML response.
///
/// Will automatically get `Content-Type: text/html`.
#[derive(Clone, Copy, Debug)]
#[must_use]
pub struct Html<T>(pub T);

impl<T> IntoResponse for Html<T>
where
    T: Into<Body>,
{
    fn into_response(self) -> Result<Response, Response> {
        const TEXT_HTML_UTF8: HeaderValue = HeaderValue::from_static("text/html; charset=utf-8");

        let mut res = Response::new(self.0.into());
        res.headers_mut().insert(header::CONTENT_TYPE, TEXT_HTML_UTF8);
        Ok(res)
    }
}

impl<T> From<T> for Html<T> {
    fn from(inner: T) -> Self {
        Self(inner)
    }
}