From f675f75b3bcd581e6af369d0a6c27ce8ed967085 Mon Sep 17 00:00:00 2001 From: Jordan Johnson-Doyle Date: Sat, 16 Feb 2019 11:48:42 +0000 Subject: [PATCH] Rename render -> show_paste --- src/main.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4da138b..5479ee9 100644 --- a/src/main.rs +++ a/src/main.rs @@ -55,7 +55,7 @@ fn submit(input: Form) -> Redirect { let id = generate_id(); store_paste(id.clone(), input.into_inner().val); - Redirect::to(uri!(render: id)) + Redirect::to(uri!(show_paste: id)) } #[put("/", data = "")] @@ -67,7 +67,7 @@ store_paste(id.clone(), data); match *host { - Some(host) => Ok(format!("https://{}/{}", host, id)), + Some(host) => Ok(format!("https://{}{}", host, uri!(show_paste: id))), None => Ok(id), } } @@ -78,12 +78,12 @@ #[derive(Template)] #[template(path = "paste.html")] -struct Render { +struct ShowPaste { content: MarkupDisplay, } #[get("/")] -fn render(key: String, plaintext: IsPlaintextRequest) -> Result, Status> { +fn show_paste(key: String, plaintext: IsPlaintextRequest) -> Result, Status> { let mut splitter = key.splitn(2, '.'); let key = splitter.next().ok_or_else(|| Status::NotFound)?; let ext = splitter.next(); @@ -95,16 +95,14 @@ if *plaintext { Ok(Content(ContentType::Plain, entry)) } else { - let template = Render { - content: match ext { - None => MarkupDisplay::new_unsafe(entry, Html), - Some(extension) => highlight(&entry, extension) - .map(|h| MarkupDisplay::new_safe(h, Html)) - .ok_or_else(|| Status::NotFound)?, - }, + let content = match ext { + None => MarkupDisplay::new_unsafe(entry, Html), + Some(extension) => highlight(&entry, extension) + .map(|h| MarkupDisplay::new_safe(h, Html)) + .ok_or_else(|| Status::NotFound)?, }; - template + ShowPaste { content } .render() .map(|html| Content(ContentType::HTML, html)) .map_err(|_| Status::InternalServerError) @@ -113,6 +111,6 @@ fn main() { rocket::ignite() - .mount("/", routes![index, submit, submit_raw, render]) + .mount("/", routes![index, submit, submit_raw, show_paste]) .launch(); } -- rgit 0.1.3