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.
56 lines
1.2 KiB
56 lines
1.2 KiB
use serde::{Deserialize, Serialize};
|
|
use std::net;
|
|
|
|
fn default_http_addr() -> Option<net::SocketAddr> {
|
|
Some("[::]:3080".parse().unwrap())
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub enum ConfigFormMethod {
|
|
GET,
|
|
POST,
|
|
}
|
|
|
|
impl ConfigFormMethod {
|
|
pub fn as_str(&self) -> &str {
|
|
match self {
|
|
Self::GET => "GET",
|
|
Self::POST => "POST",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for ConfigFormMethod {
|
|
fn default() -> Self {
|
|
Self::POST
|
|
}
|
|
}
|
|
|
|
impl AsRef<hyper::Method> for ConfigFormMethod {
|
|
fn as_ref(&self) -> &hyper::Method {
|
|
match self {
|
|
Self::GET => &hyper::Method::GET,
|
|
Self::POST => &hyper::Method::POST,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub struct Config {
|
|
#[serde(default = "default_http_addr")]
|
|
pub http_addr: Option<net::SocketAddr>,
|
|
pub https_addr: Option<net::SocketAddr>,
|
|
|
|
#[serde(default)]
|
|
pub form_method: ConfigFormMethod,
|
|
}
|
|
|
|
impl Default for Config {
|
|
fn default() -> Self {
|
|
Self {
|
|
http_addr: default_http_addr(),
|
|
https_addr: None,
|
|
form_method: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|