You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CheezeNotes/src/index.rs

27 lines
647 B

use actix_web::web;
use actix_web::{Responder, get};
use askama_actix::Template;
use askama_actix::TemplateToResponse;
use crate::commons::AppData;
use crate::db;
use crate::db::Domain;
#[derive(Template)]
#[template(path = "index.html")]
pub struct PageTemplate {
pub app_name: String,
pub base_url: String,
pub domains: Vec<Domain>,
}
#[get("/")]
async fn index(data: web::Data<AppData>) -> impl Responder {
let app_name = data.app_name.to_owned();
let base_url = data.base_url.to_owned();
let domains = db::get_domains(&data.db_pool).await.unwrap();
PageTemplate { app_name, base_url, domains }.to_response()
}