From 1daa5019aa590c661372ca346a1e84b2c79fe232 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Fri, 8 Dec 2023 15:45:08 +0100 Subject: [PATCH] feat: added an index html file --- src/api/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index 580f757..d016119 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -3,7 +3,8 @@ mod admin; mod project; mod user; -use actix_web::{web, App, HttpServer}; +use actix_web::http::header::ContentType; +use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use anyhow::Result; use log::info; use sqlx::postgres::PgPool; @@ -102,6 +103,8 @@ pub async fn start(port: u16, pool: PgPool) -> Result<()> { .service( web::scope("/admin/backup").default_service(web::to(admin::calls::backup_forward)), ) + .route("/", web::get().to(index)) + .route("/index.html", web::get().to(index)) .app_data(web::Data::new(ApiState { pool: pool.clone() })) }) .bind(("0.0.0.0", port))? @@ -110,3 +113,17 @@ pub async fn start(port: u16, pool: PgPool) -> Result<()> { Ok(()) } + +async fn index() -> impl Responder { + HttpResponse::Ok().content_type(ContentType::html()).body(r#" + + + Nerdcult API + + +

This is a http API and by that intended to be used as an interface for applications.

+

Documentation on how to use this API can be found here.

+ + + "#) +}