1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use super::*;
use crate::enums::ContactDetails;
use askama::Template;
use axum::response::Html;

pub async fn status() -> String {
    STATUS_OK.to_string()
}

#[derive(Template)]
#[template(path = "index.html")]
struct IndexTemplate {
    admin_contact: String,
}

// #[debug_handler]
pub async fn index(
    axum::extract::State(state): axum::extract::State<GoatState>,
) -> Result<Html<String>, ()> {
    let admin_contact = match state.read().await.config.admin_contact {
        ContactDetails::None => "".to_string(),
        _ => {
            format!(
                "- instance cared for by {}",
                state.read().await.config.admin_contact.to_string()
            )
        }
    };
    let context = IndexTemplate { admin_contact };
    Ok(Html::from(context.render().unwrap()))
}