mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-04-06 20:45:40 +02:00
52 lines
1.1 KiB
Rust
52 lines
1.1 KiB
Rust
use serde::{Deserialize,Serialize};
|
|
|
|
/* Response format */
|
|
|
|
#[derive(Deserialize, Serialize, Clone, Copy)]
|
|
pub enum ResponseFormat {
|
|
#[serde(rename="text/plain", alias="text")]
|
|
TextPlain,
|
|
#[serde(rename="text/html", alias="html")]
|
|
TextHtml,
|
|
#[serde(rename="application/json", alias="json")]
|
|
ApplicationJson,
|
|
}
|
|
|
|
impl ToString for ResponseFormat {
|
|
fn to_string(&self) -> String {
|
|
match self {
|
|
ResponseFormat::TextPlain => "text/plain",
|
|
ResponseFormat::TextHtml => "text/html",
|
|
ResponseFormat::ApplicationJson => "application/json",
|
|
}.to_string()
|
|
}
|
|
}
|
|
|
|
impl ResponseFormat {
|
|
pub fn to_file_extension(&self) -> String {
|
|
match self {
|
|
ResponseFormat::TextPlain => ".txt",
|
|
ResponseFormat::TextHtml => ".html",
|
|
ResponseFormat::ApplicationJson => ".json",
|
|
}.to_string()
|
|
}
|
|
}
|
|
|
|
/* Query and Template Settings */
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub struct QuerySettings {
|
|
pub format: ResponseFormat,
|
|
pub lang: String,
|
|
pub available_dns_resolvers: Vec<Selectable>,
|
|
pub dns_resolver_id: String,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub struct Selectable {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub weight: i32,
|
|
}
|
|
|