From 4046e7f185ede1c1166bc4ad4eb5bec44569539d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 31 Dec 2019 20:56:28 +0100 Subject: [PATCH] clean up the dogs example --- examples/dog_list/main.rs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/examples/dog_list/main.rs b/examples/dog_list/main.rs index d265f43..da9e1f5 100644 --- a/examples/dog_list/main.rs +++ b/examples/dog_list/main.rs @@ -2,7 +2,6 @@ #[macro_use] extern crate rocket; -use rocket::request::Form; use rocket::response::content::Html; use rocket::response::Redirect; @@ -30,38 +29,23 @@ fn index(session: Session) -> Html { - "#, - ); - + page.push_str(""); Html(page) } -#[derive(FromForm)] -struct AddForm { - name: String, -} - #[post("/add", data = "")] -fn add(session: Session, dog: Form) -> Redirect { +fn add(session: Session, dog: String) -> Redirect { session.tap(move |sess| { - sess.push(dog.into_inner().name); + sess.push(dog); }); - Redirect::found("/") } @@ -72,6 +56,5 @@ fn remove(session: Session, dog: usize) -> Redirect { sess.remove(dog); } }); - Redirect::found("/") }