Skip to content

Commit

Permalink
deny unknown fields
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhickman committed Sep 8, 2020
1 parent 5b8e5f6 commit 1f02e7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct Route {

#[derive(Debug, Deserialize)]
#[serde(tag = "kind", rename_all = "kebab-case")]
#[serde(deny_unknown_fields)]
pub enum RouteKind {
Dir(DirRoute),
File(FileRoute),
Expand All @@ -59,31 +60,35 @@ pub enum RouteKind {
}

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DirRoute {
pub path: PathBuf,
}

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FileRoute {
pub path: PathBuf,
}

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct JsonRoute {
pub path: PathBuf,
#[serde(default)]
pub pretty: bool,
}

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MockRoute {
#[serde(with = "http_serde::status_code")]
pub status: http::StatusCode,
pub body: Option<serde_json::Value>,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub struct ProxyRoute {
#[serde(rename = "url", with = "http_serde::uri")]
pub uri: Uri,
Expand Down

0 comments on commit 1f02e7d

Please sign in to comment.