From e731a5f94e1062cb62c2f8e9e123aee528b322ac Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 18 Apr 2021 10:42:14 +0200 Subject: add html_escape method --- examples/form/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/form') 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; @@ -45,8 +45,8 @@ struct FormData {text: String} async fn post_form(_req: &mut Parts, body: Body) -> Result { 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 {}", html_escape(msg.text)).into() ).unwrap()) } -- cgit v1.2.3