diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-11-18 19:55:06 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-11-18 19:55:06 -0600 |
| commit | 3f089fcc9a327b2d6a3e82cb3a2a1d5ff790b8b1 (patch) | |
| tree | 3ae8992bc36e9835c1d25cbb94645229a4a6bb9f /src/slskd/Core/API/Controllers/ConfigurationController.cs | |
| parent | 3e74ff541f60d34845b33d424aec86132ac78bb4 (diff) | |
| download | slskd-3f089fcc9a327b2d6a3e82cb3a2a1d5ff790b8b1.tar.gz | |
move yaml endpoints
Diffstat (limited to 'src/slskd/Core/API/Controllers/ConfigurationController.cs')
| -rw-r--r-- | src/slskd/Core/API/Controllers/ConfigurationController.cs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/slskd/Core/API/Controllers/ConfigurationController.cs b/src/slskd/Core/API/Controllers/ConfigurationController.cs index 08d84c0a..a7925174 100644 --- a/src/slskd/Core/API/Controllers/ConfigurationController.cs +++ b/src/slskd/Core/API/Controllers/ConfigurationController.cs @@ -58,50 +58,6 @@ namespace slskd.Core.API return Ok(OptionsSnapshot.Value); } - [HttpGet] - [Route("yaml")] - public IActionResult GetYamlFile() - { - if (!OptionsSnapshot.Value.RemoteConfiguration) - { - return Forbid(); - } - - var yaml = IOFile.ReadAllText(Program.ConfigurationFile); - return Ok(yaml); - } - - [HttpPost] - [Route("yaml")] - public IActionResult UpdateYamlFile([FromBody]string yaml) - { - if (!OptionsSnapshot.Value.RemoteConfiguration) - { - return Forbid(); - } - - if (!TryValidateYaml(yaml, out var error)) - { - Logger.Error(error, "Failed to validate YAML configuration"); - return BadRequest(error); - } - - IOFile.WriteAllText(Program.ConfigurationFile, yaml); - return Ok(); - } - - [HttpPost] - [Route("yaml/validate")] - public IActionResult ValidateYamlFile([FromBody] string yaml) - { - if (!TryValidateYaml(yaml, out var error)) - { - return BadRequest(error); - } - - return Ok(); - } - [HttpPut] [Route("shares")] [Authorize] @@ -116,22 +72,5 @@ namespace slskd.Core.API return Ok(); } - - private bool TryValidateYaml(string yaml, out string error) - { - error = null; - - try - { - _ = yaml.FromYaml<Options>(); - } - catch (Exception ex) - { - error = $"{ex.Message}: {ex.InnerException.Message}"; - return false; - } - - return true; - } } } |
