nomilo/src/routes/ui/zones.rs

27 lines
666 B
Rust
Raw Normal View History

2024-12-22 21:36:26 +00:00
use axum::extract::{Path, State};
2022-04-29 16:04:12 +00:00
use serde_json::{Value, json};
2022-04-29 02:29:10 +00:00
2024-12-22 21:36:26 +00:00
use crate::AppState;
use crate::errors::Error;
2025-03-24 22:03:54 +00:00
use crate::resources::zone::Zone;
2022-04-29 02:29:10 +00:00
use crate::template::Template;
2024-12-22 21:36:26 +00:00
pub async fn get_zone_records_page(
Path(zone_name): Path<String>,
State(app): State<AppState>,
) -> Result<Template<'static, Value>, Error> {
let records = Zone::get_records(&zone_name, app.db, app.records).await?;
2024-12-22 21:36:26 +00:00
//records.0.sort_by_key(|record| (&record.name, record.rdata));
Ok(Template::new(
2024-12-22 21:36:26 +00:00
"pages/records.html",
app.template_engine,
json!({
2024-12-22 21:36:26 +00:00
"current_zone": zone_name,
"records": records,
})
))
}