From 8e722df56c631179ff6d8f806e15e6057912eaa7 Mon Sep 17 00:00:00 2001 From: Arttu Kuikka <75498768+ArttuKuikka@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:37:20 +0200 Subject: [PATCH] App config --- src/Controllers/AppController.cs | 23 +++++++++++++++++++++++ src/GlobalConfig.cs | 2 ++ src/Models/AppConfig.cs | 12 ++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/Controllers/AppController.cs create mode 100644 src/Models/AppConfig.cs diff --git a/src/Controllers/AppController.cs b/src/Controllers/AppController.cs new file mode 100644 index 0000000..fa6dc22 --- /dev/null +++ b/src/Controllers/AppController.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Mvc; +using RuokalistaServer.Models; + +namespace RuokalistaServer.Controllers +{ + public class AppController : Controller + { + [HttpGet] + [Route("api/v1/App/Config")] + public IActionResult Config() + { + var config = new AppConfig + { + Branding = GlobalConfig.BrandingName, + PrimaryColor = GlobalConfig.PrimaryColor, + KasvisruokalistaEnabled = GlobalConfig.KasvisruokalistaEnabled, + AanestysEnabled = GlobalConfig.AanestysEnabled, + DefaultLanguage = GlobalConfig.DefaultLanguage + }; + return Json(config); + } + } +} diff --git a/src/GlobalConfig.cs b/src/GlobalConfig.cs index 3226960..85cb8e8 100644 --- a/src/GlobalConfig.cs +++ b/src/GlobalConfig.cs @@ -15,5 +15,7 @@ public static class GlobalConfig public static string BrandingName = Environment.GetEnvironmentVariable("Branding") ?? "Kouluruokalista.fi"; public static string? StaticContentHost = Environment.GetEnvironmentVariable("StaticContentHost"); + + public static string DefaultLanguage = Environment.GetEnvironmentVariable("DefaultLanguage") ?? "fin"; } } diff --git a/src/Models/AppConfig.cs b/src/Models/AppConfig.cs new file mode 100644 index 0000000..1f84ea2 --- /dev/null +++ b/src/Models/AppConfig.cs @@ -0,0 +1,12 @@ +namespace RuokalistaServer.Models +{ + public class AppConfig + { + public string Branding { get; set; } + public string PrimaryColor { get; set; } + public bool KasvisruokalistaEnabled { get; set; } + public bool AanestysEnabled { get; set; } + public string DefaultLanguage { get; set; } + + } +}