From 592660a5ca6f88375f5ec7b7543b110bbf8479ac Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 26 May 2022 16:51:38 -0500 Subject: add an endpoint to get configuration debug view --- src/slskd/Core/API/Controllers/OptionsController.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/slskd/Core/API/Controllers') diff --git a/src/slskd/Core/API/Controllers/OptionsController.cs b/src/slskd/Core/API/Controllers/OptionsController.cs index 062de8f7..b0856ed3 100644 --- a/src/slskd/Core/API/Controllers/OptionsController.cs +++ b/src/slskd/Core/API/Controllers/OptionsController.cs @@ -21,8 +21,10 @@ namespace slskd.Core.API { using System; using System.IO; + using System.Reflection; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; + using Microsoft.Extensions.Configuration; using Serilog; using slskd.Validation; using IOFile = System.IO.File; @@ -74,6 +76,24 @@ namespace slskd.Core.API return Ok(OptionsAtStartup.Redact()); } + /// + /// Gets the debug view of the current application options. + /// + /// + [HttpGet] + [Route("debug")] + [Authorize] + [ProducesResponseType(typeof(string), 200)] + public IActionResult Debug() + { + // retrieve the IConfigurationRoot instance with reflection to avoid + // exposing it as a public member of Program. + var property = typeof(Program).GetProperty("Configuration", BindingFlags.NonPublic | BindingFlags.Static); + var configurationRoot = (IConfigurationRoot)property.GetValue(null, null); + + return Ok(configurationRoot.GetDebugView()); + } + [HttpGet] [Authorize] [Route("yaml/location")] -- cgit v1.2.3