diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-05 06:28:52 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-05 06:28:52 +0200 |
commit | cf455ed8de20bbee011289223e7d8d5775dfd69e (patch) | |
tree | cbdfdbc207af64a105b4d21941a6f0e71ca65e9d /Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs | |
parent | Add start of Media Moderator PoC bot (diff) | |
download | LibMatrix-cf455ed8de20bbee011289223e7d8d5775dfd69e.tar.xz |
Media moderator PoC works, abstract command handling to library
Diffstat (limited to 'Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs')
-rw-r--r-- | Utilities/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs | 26 |
1 files changed, 26 insertions, 0 deletions
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<ValidationController> _logger; + + public ValidationController(ILogger<ValidationController> logger) { + _logger = logger; + } + + [HttpPost("/validate/{type}")] + public Task<bool> 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, "$")); + } +} |