#![feature(decl_macro)] use rocket::{*, response::Redirect, form::Form}; use rocket_dyn_templates::{Template, context}; #[get("/create")] fn begin_create() -> Template { Template::render("begin_create", context!{}) } #[get("/create/")] fn create(name: &str) -> Template { Template::render("create", context!{ username: name }) } #[derive(FromForm)] struct UserNameData<'r> { pub username: &'r str, } #[post("/create", data = "")] fn create_post(name: Form>) -> Redirect { Redirect::to(uri!(create(name.username))) } #[get("/about")] fn about() -> Template { Template::render("about", context!{}) } #[get("/")] fn index() -> Template { Template::render("index", context! { create_uri: uri!(begin_create()) }) } #[launch] fn rocket() -> _ { rocket::build().mount("/", routes![begin_create, create, create_post, index, about]).attach(Template::fairing()) }