From f10be383f90d9246a4c15b29142249d4fc06b7c9 Mon Sep 17 00:00:00 2001 From: saw <> Date: Fri, 4 Jun 2021 13:03:16 -0400 Subject: [PATCH] Post error message, build number Made the error when you try to post without being logged in more informative. It used to be very vague and confusing. Added build number to home page and backend banner. It pulls the version number from cargo at compile time. --- Cargo.toml | 2 +- src/html/boards.rs | 2 +- src/main.rs | 8 ++++---- src/res/banner | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3822acd..040f51c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "board_server" -version = "1.0.0" +version = "1.0.1" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/html/boards.rs b/src/html/boards.rs index b30617f..879d2f3 100644 --- a/src/html/boards.rs +++ b/src/html/boards.rs @@ -146,7 +146,7 @@ pub async fn board_post( Ok(a) => a, Err(e) => { println!("{}", e); - return Err(HttpResponse::BadRequest().body("Bad Request: Could not parse cookie data")); + return Err(HttpResponse::BadRequest().body("Bad Request: Could not parse cookie data.\n Not logged in, or bad cookie.")); } }; let mut mf = data.msg_factory.lock().unwrap(); diff --git a/src/main.rs b/src/main.rs index 680fad3..0b0a644 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,12 +59,12 @@ impl PageBuilder { #[get("/")] async fn index() -> impl Responder { - HttpResponse::Ok().body(r#" + HttpResponse::Ok().body(format!(r#" -

Boarders v1.0.0

+

Boarders v{}

What is it?

Boarders is an easily deployable message board written in Rust. @@ -88,7 +88,7 @@ Don't ruin the fun for everyone

------[Get Started]------

-"#) +"#, env!("CARGO_PKG_VERSION"))) } #[get("/debug/")] @@ -195,7 +195,7 @@ async fn main() -> std::io::Result<()> { }).bind("127.0.0.1:8080")? .run(); println!("Started server"); - println!("{}", include_str!("res/banner")); + println!("{}v{}", include_str!("res/banner"), env!("CARGO_PKG_VERSION")); let res = server.await; println!("\nExiting..."); /* diff --git a/src/res/banner b/src/res/banner index a9e185f..801913f 100644 --- a/src/res/banner +++ b/src/res/banner @@ -1,5 +1,5 @@ - __ __ - / /_ ____ ____ _ _____ ____/ / _____ _____ - / __ \ / __ \ / __ `// ___// __ / / ___// ___/ - / /_/ // /_/ // /_/ // / / /_/ /_ / / (__ ) -/_.___/ \____/ \__,_//_/ \__,_/(_)/_/ /____/ + ____ __ + / __ ) ____ ____ _ _____ ____/ /___ _____ _____ + / __ |/ __ \ / __ `// ___// __ // _ \ / ___// ___/ + / /_/ // /_/ // /_/ // / / /_/ // __// / (__ ) +/_____/ \____/ \__,_//_/ \__,_/ \___//_/ /____/