From 5e7249484bdbc37ea7effea2507fe7aa4f53e56d Mon Sep 17 00:00:00 2001 From: Gitznik Date: Fri, 5 Jan 2024 22:45:21 +0100 Subject: [PATCH] add head route for root --- src/configuration.rs | 2 ++ src/main.rs | 3 ++- src/routes/root/get.rs | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/configuration.rs b/src/configuration.rs index 530b33c..22597b6 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -25,6 +25,7 @@ pub fn get_configuration() -> Result { .unwrap_or_else(|_| "dev".into()) .try_into() .expect("Failed to parse APP_ENVIRONMENT"); + println!("Running in environment {:?}", environment); let environment_filename = format!("{}.yaml", environment.as_str()); match environment { Environment::Dev => {} @@ -52,6 +53,7 @@ pub fn get_configuration() -> Result { settings.try_deserialize::() } +#[derive(Debug)] pub enum Environment { Dev, Production, diff --git a/src/main.rs b/src/main.rs index e232b0f..3c076e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use robswebhub::{ configuration::get_configuration, routes::{ about::get::about, - root::get::root, + root::get::{root, root_head}, scores::{get::add_scores, post::save_scores}, }, }; @@ -37,6 +37,7 @@ async fn main() -> std::io::Result<()> { App::new() .wrap(message_framework.clone()) .service(root) + .service(root_head) .service(about) .service(add_scores) .service(save_scores) diff --git a/src/routes/root/get.rs b/src/routes/root/get.rs index 193a7ea..087960d 100644 --- a/src/routes/root/get.rs +++ b/src/routes/root/get.rs @@ -1,4 +1,4 @@ -use actix_web::{get, HttpResponse, Responder}; +use actix_web::{get, HttpResponse, Responder, head}; use crate::html_base::compose_html; @@ -8,3 +8,8 @@ async fn root() -> impl Responder { let html = compose_html(main_div); HttpResponse::Ok().body(html) } + +#[head("/")] +async fn root_head() -> impl Responder { + HttpResponse::Ok() +}