2023-08-05 22:53:48 +02:00
|
|
|
use serde::{Deserialize,Serialize};
|
2023-08-05 23:19:53 +02:00
|
|
|
|
2023-10-30 01:22:27 +01:00
|
|
|
use lib_humus::HtmlTextJsonFormat;
|
|
|
|
use lib_humus::HumusQuerySettings;
|
|
|
|
|
2023-10-08 09:12:06 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2023-08-05 22:53:48 +02:00
|
|
|
/* Response format */
|
|
|
|
|
2023-10-29 15:23:47 +01:00
|
|
|
pub type ResponseFormat = HtmlTextJsonFormat;
|
2023-08-05 22:53:48 +02:00
|
|
|
|
|
|
|
/* Query and Template Settings */
|
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
|
|
pub struct QuerySettings {
|
|
|
|
pub format: ResponseFormat,
|
|
|
|
pub lang: String,
|
|
|
|
pub available_dns_resolvers: Vec<Selectable>,
|
2023-10-08 09:12:06 +02:00
|
|
|
pub dns_resolver_id: Arc<str>,
|
2024-04-21 00:00:04 +02:00
|
|
|
pub dns_disable_self_lookup: bool,
|
2023-08-05 22:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
|
|
pub struct Selectable {
|
2023-10-08 09:12:06 +02:00
|
|
|
pub id: Arc<str>,
|
|
|
|
pub name: Arc<str>,
|
2023-08-05 23:19:53 +02:00
|
|
|
pub weight: i32,
|
2023-08-05 22:53:48 +02:00
|
|
|
}
|
|
|
|
|
2023-10-30 01:22:27 +01:00
|
|
|
impl HumusQuerySettings<ResponseFormat> for QuerySettings {
|
2023-10-29 18:10:57 +01:00
|
|
|
|
|
|
|
fn initalize_template_context(&self, context: &mut tera::Context) {
|
|
|
|
context.insert("language", &self.lang);
|
|
|
|
context.insert("dns_resolvers", &self.available_dns_resolvers);
|
|
|
|
context.insert("dns_resolver_id", &self.dns_resolver_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_format(&self) -> ResponseFormat {
|
|
|
|
self.format.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|