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.
30 lines
791 B
30 lines
791 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::Page;
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "domain.html")]
|
|
pub struct DomainTemplate {
|
|
pub app_name: String,
|
|
pub base_url: String,
|
|
pub domain: String,
|
|
pub pages: Vec<Page>,
|
|
}
|
|
|
|
#[get("/{domaine}")]
|
|
async fn domain(path: web::Path<String>, data: web::Data<AppData>) -> impl Responder {
|
|
let app_name = data.app_name.to_owned();
|
|
let base_url = data.base_url.to_owned();
|
|
let domain = path.to_string();
|
|
|
|
let pages = db::get_pages_by_domain(&data.db_pool, domain.to_owned()).await.unwrap();
|
|
|
|
DomainTemplate { app_name, base_url, domain: domain.to_owned(), pages }.to_response()
|
|
}
|