Skip to content

Commit f95975a

Browse files
committed
Added AsHtml
1 parent fb5568c commit f95975a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

my-http-server-core/src/http_output.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ impl HttpOutput {
131131
}
132132
}
133133

134+
pub fn as_html<'s>(text: impl Into<StrOrString<'s>>) -> HttpResultBuilder {
135+
let text = text.into().to_string();
136+
137+
HttpResultBuilder {
138+
status_code: 200,
139+
headers: None,
140+
content_type: Some(WebContentType::Html),
141+
cookies: Default::default(),
142+
content: text.into_bytes(),
143+
}
144+
}
145+
134146
pub fn as_json<T: Serialize>(model: T) -> HttpResultBuilder {
135147
let json = serde_json::to_vec(&model).unwrap();
136148

0 commit comments

Comments
 (0)