From cf455ed8de20bbee011289223e7d8d5775dfd69e Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 5 Sep 2023 06:28:52 +0200 Subject: Media moderator PoC works, abstract command handling to library --- .../Controllers/ValidationController.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs (limited to 'Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs') diff --git a/Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs b/Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs new file mode 100644 index 0000000..4dbee54 --- /dev/null +++ b/Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs @@ -0,0 +1,26 @@ +using System.Text.Json; +using LibMatrix.Extensions; +using Microsoft.AspNetCore.Mvc; + +namespace LibMatrix.DebugDataValidationApi.Controllers; + +[ApiController] +[Route("/")] +public class ValidationController : ControllerBase { + private readonly ILogger _logger; + + public ValidationController(ILogger logger) { + _logger = logger; + } + + [HttpPost("/validate/{type}")] + public Task Get([FromRoute] string type, [FromBody] JsonElement content) { + var t = Type.GetType(type); + if (t is null) { + Console.WriteLine($"Type `{type}` does not exist!"); + throw new ArgumentException($"Unknown type {type}!"); + } + Console.WriteLine($"Validating {type}..."); + return Task.FromResult(content.FindExtraJsonElementFields(t, "$")); + } +} -- cgit 1.4.1