From 1bd30ee34323f150c63fc537e0d131dca29dc4ef Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 5 Jun 2022 00:19:10 +0200 Subject: refactor: Implement caching in VaultService and use VaultService instead of IOptions --- .../Endpoints/Internal/Root/ReadConfigurationRoute.cs | 17 +++++++++++++++++ .../Internal/Root/RefreshConfigurationRoute.cs | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs create mode 100644 server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs (limited to 'server/src/Endpoints/Internal') diff --git a/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs b/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs new file mode 100644 index 0000000..e0dcca3 --- /dev/null +++ b/server/src/Endpoints/Internal/Root/ReadConfigurationRoute.cs @@ -0,0 +1,17 @@ +namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; + +public class ReadConfigurationRoute : RouteBaseSync.WithoutRequest.WithActionResult +{ + private readonly VaultService _vaultService; + + public ReadConfigurationRoute(VaultService vaultService) { + _vaultService = vaultService; + } + + [AllowAnonymous] + [HttpGet("~/_/configuration")] + public override ActionResult Handle() { + var config = _vaultService.GetCurrentAppConfiguration(); + return Content(JsonSerializer.Serialize(config.GetPublicVersion()), "application/json"); + } +} diff --git a/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs b/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs new file mode 100644 index 0000000..4b1beec --- /dev/null +++ b/server/src/Endpoints/Internal/Root/RefreshConfigurationRoute.cs @@ -0,0 +1,15 @@ +namespace IOL.GreatOffice.Api.Endpoints.Internal.Root; + +public class RefreshConfigurationRoute : RouteBaseSync.WithoutRequest.WithoutResult +{ + private readonly VaultService _vaultService; + + public RefreshConfigurationRoute(VaultService vaultService) { + _vaultService = vaultService; + } + + [HttpGet("~/_/refresh-configuration")] + public override void Handle() { + _vaultService.RefreshCurrentAppConfiguration(); + } +} -- cgit v1.3