From 1979d604b05db7c12f1608fa73d9d9d55a35916e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 20 May 2021 00:07:40 -0400 Subject: [PATCH] index page --- Cargo.lock | 1 + src/endpoints/mod.rs | 1 + src/endpoints/root_index.rs | 11 +++++++++++ src/main.rs | 2 ++ 4 files changed, 15 insertions(+) create mode 100644 src/endpoints/root_index.rs diff --git a/Cargo.lock b/Cargo.lock index b79981f40f..1fa0885f1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2455,6 +2455,7 @@ dependencies = [ "bitflags", "byteorder", "bytes 1.0.1", + "chrono", "crc", "crossbeam-channel", "crossbeam-queue", diff --git a/src/endpoints/mod.rs b/src/endpoints/mod.rs index e3146d353b..daae90cd5b 100644 --- a/src/endpoints/mod.rs +++ b/src/endpoints/mod.rs @@ -1 +1,2 @@ +pub mod root_index; pub mod users; \ No newline at end of file diff --git a/src/endpoints/root_index.rs b/src/endpoints/root_index.rs new file mode 100644 index 0000000000..aa1c45e309 --- /dev/null +++ b/src/endpoints/root_index.rs @@ -0,0 +1,11 @@ +use actix_http::http::StatusCode; +use actix_web::{HttpResponse, HttpRequest, Responder, get}; +use log::info; + +#[get("/")] +pub async fn get_root_index() -> impl Responder { + info!("GET /"); + HttpResponse::build(StatusCode::OK) + .content_type("text/html; charset=utf-8") + .body("

hello friend

") +} diff --git a/src/main.rs b/src/main.rs index 3f19ba2024..0fe338815c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ use crate::util::cookies::CookieManager; use crate::endpoints::users::logout::logout_handler; use crate::util::session_checker::SessionChecker; use crate::endpoints::users::session_info::session_info_handler; +use crate::endpoints::root_index::get_root_index; const DEFAULT_BIND_ADDRESS : &'static str = "0.0.0.0:12345"; const DEFAULT_RUST_LOG: &'static str = "debug,actix_web=info"; @@ -156,6 +157,7 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()> .route(web::get().to(session_info_handler)) .route(web::head().to(|| HttpResponse::Ok())) ) + .service(get_root_index) }) .bind(bind_address)? .workers(num_workers)