rama_http/service/web/endpoint/response/
html.rs1use super::IntoResponse;
2use crate::headers::ContentType;
3use crate::{Body, Response};
4use rama_utils::macros::impl_deref;
5use std::fmt;
6
7use super::Headers;
8
9pub struct Html<T>(pub T);
13
14impl<T: fmt::Debug> fmt::Debug for Html<T> {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 f.debug_tuple("Html").field(&self.0).finish()
17 }
18}
19
20impl<T: Clone> Clone for Html<T> {
21 fn clone(&self) -> Self {
22 Self(self.0.clone())
23 }
24}
25
26impl_deref!(Html);
27
28impl<T> IntoResponse for Html<T>
29where
30 T: Into<Body>,
31{
32 fn into_response(self) -> Response {
33 (Headers::single(ContentType::html_utf8()), self.0.into()).into_response()
34 }
35}
36
37impl<T> From<T> for Html<T> {
38 fn from(inner: T) -> Self {
39 Self(inner)
40 }
41}