Fix deserialization of FlatDomainSettings boolean flags
This commit is contained in:
parent
ccd2285b11
commit
63f4975d5a
@ -1,9 +1,22 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{de, Deserialize, Serialize};
|
||||
|
||||
use crate::{domain, error::unexpected, origin};
|
||||
|
||||
fn deserialize_bool<'de, D>(deserializer: D) -> Result<bool, D::Error>
|
||||
where
|
||||
D: de::Deserializer<'de>,
|
||||
{
|
||||
let s: &str = de::Deserialize::deserialize(deserializer)?;
|
||||
|
||||
match s {
|
||||
"true" => Ok(true),
|
||||
"false" => Ok(false),
|
||||
_ => Err(de::Error::unknown_variant(s, &["true", "false"])),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub struct FlatDomainSettings {
|
||||
domain_setting_origin_descr_kind: String,
|
||||
@ -14,8 +27,11 @@ pub struct FlatDomainSettings {
|
||||
domain_setting_origin_descr_proxy_url: Option<String>,
|
||||
|
||||
#[serde(default)]
|
||||
#[serde(deserialize_with = "deserialize_bool")]
|
||||
domain_setting_serve_protocol_http: bool,
|
||||
|
||||
#[serde(default)]
|
||||
#[serde(deserialize_with = "deserialize_bool")]
|
||||
domain_setting_serve_protocol_https: bool,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user