From c2219e15f403eab61c730ca03462c79c27f22234 Mon Sep 17 00:00:00 2001 From: Jordan Johnson-Doyle Date: Thu, 21 Feb 2019 11:51:36 +0000 Subject: [PATCH] Avoid cloning generated id when submitting paste --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d280a05..47e33d8 100644 --- a/src/main.rs +++ a/src/main.rs @@ -55,8 +55,9 @@ #[post("/", data = "")] fn submit(input: Form) -> Redirect { let id = generate_id(); - store_paste(id.clone(), input.into_inner().val); - Redirect::to(uri!(show_paste: id)) + let uri = uri!(show_paste: &id); + store_paste(id, input.into_inner().val); + Redirect::to(uri) } #[put("/", data = "")] @@ -65,11 +66,13 @@ input.open().take(1024 * 1000).read_to_string(&mut data)?; let id = generate_id(); - store_paste(id.clone(), data); + let uri = uri!(show_paste: &id); + store_paste(id, data); + match *host { - Some(host) => Ok(format!("https://{}{}", host, uri!(show_paste: id))), - None => Ok(id), + Some(host) => Ok(format!("https://{}{}", host, uri)), + None => Ok(format!("{}", uri)), } } -- rgit 0.1.3