30 lines
1004 B
C#
30 lines
1004 B
C#
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Text.Json;
|
|
|
|
namespace Expose.MyIT.Server.Controllers;
|
|
|
|
[ApiController]
|
|
public class AppSettingsController : ControllerBase, IAppSettingsController
|
|
{
|
|
|
|
private readonly Models.AppSettings _AppSettings;
|
|
|
|
public AppSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
|
|
|
[Route("api/[controller]")]
|
|
[HttpGet]
|
|
public string[] GetAppSettings()
|
|
{
|
|
List<string> results = new();
|
|
string json = JsonSerializer.Serialize(_AppSettings);
|
|
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
|
JsonProperty[] jsonProperties = jsonElement.EnumerateObject().ToArray();
|
|
foreach (JsonProperty jsonProperty in jsonProperties)
|
|
results.Add(jsonProperty.Value.ToString());
|
|
if (!_AppSettings.IsDevelopment)
|
|
throw new Exception("Shouldn't expose!");
|
|
return results.ToArray();
|
|
}
|
|
|
|
} |