Skip to content

Commit

Permalink
add head route for root
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitznik committed Jan 5, 2024
1 parent c53a53a commit 5e72494
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn get_configuration() -> Result<Settings, config::ConfigError> {
.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 => {}
Expand Down Expand Up @@ -52,6 +53,7 @@ pub fn get_configuration() -> Result<Settings, config::ConfigError> {
settings.try_deserialize::<Settings>()
}

#[derive(Debug)]
pub enum Environment {
Dev,
Production,
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
};
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/routes/root/get.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use actix_web::{get, HttpResponse, Responder};
use actix_web::{get, HttpResponse, Responder, head};

use crate::html_base::compose_html;

Expand All @@ -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()
}

0 comments on commit 5e72494

Please sign in to comment.