From 3f089fcc9a327b2d6a3e82cb3a2a1d5ff790b8b1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 18 Nov 2021 19:55:06 -0600 Subject: move yaml endpoints --- .../API/Controllers/ConfigurationController.cs | 61 ---------------------- 1 file changed, 61 deletions(-) (limited to 'src/slskd/Core/API/Controllers/ConfigurationController.cs') 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(); - } - catch (Exception ex) - { - error = $"{ex.Message}: {ex.InnerException.Message}"; - return false; - } - - return true; - } } } -- cgit v1.2.3