|
| 1 | +use std::path::PathBuf; |
| 2 | + |
1 | 3 | use super::error::ConfigFileError; |
2 | 4 | use super::models::{AddRuleSetsRequest, IgnoreRuleRequest}; |
3 | 5 | use super::static_analysis_config_file::StaticAnalysisConfigFile; |
@@ -43,17 +45,19 @@ pub fn post_rulesets(request: Json<AddRuleSetsRequest>) -> Result<String, Custom |
43 | 45 | } |
44 | 46 |
|
45 | 47 | #[instrument()] |
46 | | -#[rocket::get("/v1/config/rulesets/<content>")] |
47 | | -pub fn get_rulesets(content: &str) -> Json<Vec<String>> { |
48 | | - tracing::debug!(%content); |
49 | | - Json(StaticAnalysisConfigFile::to_rulesets(content.to_string())) |
| 48 | +#[rocket::get("/v1/config/rulesets/<content..>")] |
| 49 | +pub fn get_rulesets(content: PathBuf) -> Json<Vec<String>> { |
| 50 | + let content_str = content.to_string_lossy().into_owned(); |
| 51 | + tracing::debug!(%content_str); |
| 52 | + Json(StaticAnalysisConfigFile::to_rulesets(content_str)) |
50 | 53 | } |
51 | 54 |
|
52 | 55 | #[instrument()] |
53 | | -#[rocket::get("/v1/config/can-onboard/<content>")] |
54 | | -pub fn can_onboard(content: &str) -> Result<Json<bool>, Custom<ConfigFileError>> { |
55 | | - tracing::debug!(%content); |
56 | | - let config = StaticAnalysisConfigFile::try_from(content.to_string()) |
| 56 | +#[rocket::get("/v1/config/can-onboard/<content..>")] |
| 57 | +pub fn can_onboard(content: PathBuf) -> Result<Json<bool>, Custom<ConfigFileError>> { |
| 58 | + let content_str = content.to_string_lossy().into_owned(); |
| 59 | + tracing::debug!(%content_str); |
| 60 | + let config = StaticAnalysisConfigFile::try_from(content_str) |
57 | 61 | .map_err(|e| Custom(Status::InternalServerError, e))?; |
58 | 62 | let can_onboard = config.is_onboarding_allowed(); |
59 | 63 | Ok(Json(can_onboard)) |
|
0 commit comments