Skip to main content

rama_http/service/web/endpoint/response/
html.rs

1use super::{Headers, IntoResponse};
2use crate::headers::ContentType;
3use crate::{Body, Response};
4use rama_utils::macros::impl_deref;
5
6/// An HTML response.
7///
8/// Will automatically get `Content-Type: text/html`.
9#[derive(Debug, Clone, Copy)]
10pub struct Html<T>(pub T);
11
12impl_deref!(Html);
13
14impl<T> IntoResponse for Html<T>
15where
16    T: Into<Body>,
17{
18    fn into_response(self) -> Response {
19        (Headers::single(ContentType::html_utf8()), self.0.into()).into_response()
20    }
21}
22
23impl<T> From<T> for Html<T> {
24    fn from(inner: T) -> Self {
25        Self(inner)
26    }
27}