feat: added an index html file
Build and Deploy / build-docker (push) Successful in 5m39s Details

This commit is contained in:
antifallobst 2023-12-08 15:45:08 +01:00
parent a86c48ee22
commit 1daa5019aa
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
1 changed files with 18 additions and 1 deletions

View File

@ -3,7 +3,8 @@ mod admin;
mod project; mod project;
mod user; 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 anyhow::Result;
use log::info; use log::info;
use sqlx::postgres::PgPool; use sqlx::postgres::PgPool;
@ -102,6 +103,8 @@ pub async fn start(port: u16, pool: PgPool) -> Result<()> {
.service( .service(
web::scope("/admin/backup").default_service(web::to(admin::calls::backup_forward)), 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() })) .app_data(web::Data::new(ApiState { pool: pool.clone() }))
}) })
.bind(("0.0.0.0", port))? .bind(("0.0.0.0", port))?
@ -110,3 +113,17 @@ pub async fn start(port: u16, pool: PgPool) -> Result<()> {
Ok(()) Ok(())
} }
async fn index() -> impl Responder {
HttpResponse::Ok().content_type(ContentType::html()).body(r#"
<html>
<head>
<title>Nerdcult API</title>
</head>
<body>
<p>This is a http API and by that intended to be used as an interface for applications.</p>
<p>Documentation on how to use this API can be found <a href="https://git.nerdcult.net/nerdcult/api/src/branch/master/docs">here</a>.</p>
</body>
</html>
"#)
}