first
This commit is contained in:
24
TorchRemote.Plugin/Controllers/SettingsController.cs
Normal file
24
TorchRemote.Plugin/Controllers/SettingsController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using Swan;
|
||||
using TorchRemote.Models.Responses;
|
||||
using TorchRemote.Plugin.Utils;
|
||||
namespace TorchRemote.Plugin.Controllers;
|
||||
|
||||
public class SettingsController : WebApiController
|
||||
{
|
||||
private const string RootPath = "/settings";
|
||||
|
||||
[Route(HttpVerbs.Get, $"{RootPath}/{{id}}")]
|
||||
public SettingInfoResponse Get(Guid id)
|
||||
{
|
||||
if (!Statics.SettingManager.Settings.TryGetValue(id, out var setting))
|
||||
throw HttpException.NotFound($"Setting with id {id} not found", id);
|
||||
|
||||
return new(setting.Name.Humanize(), setting.Properties.Select(b =>
|
||||
new SettingPropertyInfo(b.DisplayInfo?.Name ?? b.Name.Humanize(),
|
||||
b.DisplayInfo?.Description, b.DisplayInfo?.Order, b.TypeId))
|
||||
.ToArray());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user