From d5503ca13e998de615ed9b757ff542d953b16707 Mon Sep 17 00:00:00 2001 From: Loretta Date: Tue, 14 Jul 2026 07:47:07 +0200 Subject: [PATCH] Centralize BaseUrl logic via AcEnv; enforce fail-fast Refactored BaseUrl handling so FruitBankConstClient delegates all access to AcEnv.BaseUrl in AyCode.Core, ensuring a single source of truth and fail-fast validation. Removed redundant _baseUrl field and logic from FruitBankConstClient. Updated startup files to hydrate BaseUrl from configuration and improved comments to clarify the new delegation and configuration conventions. --- AyCode.Core/Consts/AcEnv.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AyCode.Core/Consts/AcEnv.cs b/AyCode.Core/Consts/AcEnv.cs index 7cd6b2f..c421026 100644 --- a/AyCode.Core/Consts/AcEnv.cs +++ b/AyCode.Core/Consts/AcEnv.cs @@ -22,6 +22,18 @@ namespace AyCode.Core.Consts public static ulong MaxLogItemsPerSession = 250; + /// + /// A szerver base URL-je (pl. "https://localhost:59579") — a kliens-hostok hidratálják induláskor + /// a configból (konvenció: "AyCode:Urls:BaseUrl"). A hub-/link-URL-ek EBBŐL az egy értékből származnak. + /// Fail-fast: hidratálatlan olvasás exception — hiányzó/rossz URL-lel nem megyünk tovább csendben. + /// + private static string? _baseUrl; + public static string BaseUrl + { + get => !string.IsNullOrWhiteSpace(_baseUrl) ? _baseUrl : throw new InvalidOperationException("AcEnv.BaseUrl nincs beállítva — a host indulásakor hidratáld a configból (konvenció: 'AyCode:Urls:BaseUrl')."); + set => _baseUrl = value; + } + private static IConfiguration? _appConfiguration = null; public static IConfiguration AppConfiguration => _appConfiguration ??= GetAppSettingsConfiguration();