aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-04-18 10:42:14 +0200
committerMartin Fischer <martin@push-f.com>2021-04-18 10:42:14 +0200
commite731a5f94e1062cb62c2f8e9e123aee528b322ac (patch)
treefb2f25370e170564a53c93d246c3ca556ed88a21 /examples
parentd6b193f4adc29421901d7a27e3fba33dd6b14978 (diff)
add html_escape methodv0.4.1
Diffstat (limited to 'examples')
-rw-r--r--examples/form/src/main.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/form/src/main.rs b/examples/form/src/main.rs
index 9e6748e..a63560c 100644
--- a/examples/form/src/main.rs
+++ b/examples/form/src/main.rs
@@ -4,7 +4,7 @@ use hyper::{Method, Server, StatusCode, Body};
use hyper::http::request::Parts;
use hyper::http::response::Builder;
use serde::Deserialize;
-use sputnik::{mime, request::SputnikParts, response::SputnikBuilder};
+use sputnik::{html_escape, mime, request::SputnikParts, response::SputnikBuilder};
use sputnik::hyper_body::{SputnikBody, FormError};
type Response = hyper::Response<Body>;
@@ -45,8 +45,8 @@ struct FormData {text: String}
async fn post_form(_req: &mut Parts, body: Body) -> Result<Response, Error> {
let msg: FormData = body.into_form().await?;
- Ok(Builder::new().body(
- format!("hello {}", msg.text).into()
+ Ok(Builder::new().content_type(mime::TEXT_HTML).body(
+ format!("hello <em>{}</em>", html_escape(msg.text)).into()
).unwrap())
}