diff --git a/Cargo.toml b/Cargo.toml index 03cf6b9..fc4dc7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "droneconf" -version = "0.1.0" +version = "1.0.0" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 81fda44..38b5ff5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,7 @@ async fn on_request( Json(body): Json, Extension(APIConfig(client)): Extension, ) -> Result { - let conf = body.config(); + let conf = body.config().ok_or(Error::NoContent)?; if conf.starts_with("http://") || conf.starts_with("https://") { let drone_config = client.get(conf).send().await?.text().await?; let response = Response { data: drone_config }; diff --git a/src/model.rs b/src/model.rs index b1f0bd9..c0e760e 100644 --- a/src/model.rs +++ b/src/model.rs @@ -8,7 +8,9 @@ pub struct Request { #[derive(Deserialize)] pub struct Repository { - pub config_path: String, + pub config_path: Option, + pub config_file: Option, + pub config: Option, } #[derive(Serialize)] @@ -20,7 +22,7 @@ pub struct Response { pub struct APIConfig(pub Client); impl Request { - pub fn config(&self) -> String { - self.repo.config_path.clone() + pub fn config(&self) -> Option { + self.repo.config_path.clone().or(self.repo.config_file.clone()).or(self.repo.config.clone()) } }