aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/README.md b/README.md
index 30ef9c5..7d88c25 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Protect your application against [CSRF](https://en.wikipedia.org/wiki/Cross-site
by setting `SameSite` to `Lax` or `Strict` for your cookies and checking that the `Origin`
header matches your domain name (especially if you have unauthenticated POST endpoints).
-## Example
+## Hyper Example
```rust
use std::convert::Infallible;
@@ -41,7 +41,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>;
@@ -82,8 +82,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())
}