mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-16 14:03:28 +02:00
Moved to a more genral implementation for the response format.
This commit is contained in:
@ -1,38 +1,11 @@
|
||||
use serde::{Deserialize,Serialize};
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::mycelium::HtmlTextJsonFormat;
|
||||
|
||||
/* 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()
|
||||
}
|
||||
}
|
||||
pub type ResponseFormat = HtmlTextJsonFormat;
|
||||
|
||||
/* Query and Template Settings */
|
||||
|
||||
|
Reference in New Issue
Block a user