Forráskód Böngészése

refactor(config): remove WebConfig system in favor of env vars

Simplify configuration by removing the WebConfig system. Port resolution
now follows a simpler priority: constructor argument > ASTRALIS_PORT
environment variable > default (8080).

BREAKING CHANGE: WebConfig, WebConfigLoader, WebConfigSection,
WebConfigError, and ConfigMerger classes are removed
Billy Barrow 1 hónapja
szülő
commit
14e4242a17
3 módosított fájl, 4 hozzáadás és 48 törlés
  1. 0 7
      examples/meson.build
  2. 4 36
      src/Core/WebApplication.vala
  3. 0 5
      src/meson.build

+ 0 - 7
examples/meson.build

@@ -109,10 +109,3 @@ executable('sse-example',
     dependencies: [astralis_dep, invercargill_dep],
     install: false
 )
-
-# WebConfig Example - demonstrates configuration management with WebConfig
-executable('web-config-example',
-    'WebConfigExample.vala',
-    dependencies: [astralis_dep, invercargill_dep],
-    install: false
-)

+ 4 - 36
src/Core/WebApplication.vala

@@ -5,52 +5,20 @@ namespace Astralis {
 
         public Container container { get; private set; }
         public int port { get; private set; }
-        
-        /**
-         * The application configuration loaded from web-config.json
-         */
-        public WebConfig config { get; private set; }
 
-        private Server? server;
+        private Server server;
         private Pipeline pipeline;
-        private bool _port_explicitly_set;
 
         public WebApplication(int? port = null) {
-            this._port_explicitly_set = (port != null);
-            this.port = port ?? 0;
+            this.port = port ?? int.parse(Environment.get_variable ("ASTRALIS_PORT") ?? "8080");
+            printerr(@"[Astralis] Web application using port $(port)\n");
 
             container = new Container();
             pipeline = new Pipeline(container);
-            // Server is created in run() after config is loaded
+            server = new Server(this.port, pipeline);
         }
 
         public void run() throws Error {
-            // Load configuration
-            config = WebConfigLoader.load();
-            
-            // Resolve port if not explicitly set in constructor
-            // Priority: constructor arg > config file > env var > default (8080)
-            if (!_port_explicitly_set) {
-                if (config.has_key("port")) {
-                    port = config.get_int("port", 8080);
-                } else {
-                    string? env_port = Environment.get_variable("ASTRALIS_PORT");
-                    if (env_port != null) {
-                        port = int.parse(env_port);
-                    } else {
-                        port = 8080;
-                    }
-                }
-            }
-            
-            printerr(@"[Astralis] Web application using port $port\n");
-            
-            // Create server with resolved port
-            server = new Server(port, pipeline);
-            
-            // Register config as singleton in DI container
-            add_singleton<WebConfig>(() => config);
-            
             // Ensure router is registered last so that it is the last component in the pipeline.
             add_component<EndpointRouter>();
 

+ 0 - 5
src/meson.build

@@ -6,11 +6,6 @@ sources = files(
     'Core/AsyncOutput.vala',
     'Core/Pipeline.vala',
     'Core/WebApplication.vala',
-    'Core/WebConfigError.vala',
-    'Core/WebConfig.vala',
-    'Core/WebConfigSection.vala',
-    'Core/WebConfigLoader.vala',
-    'Core/ConfigMerger.vala',
     'Data/FormDataParser.vala',
     'Components/EndpointRouter.vala',
     'Components/Compressor.vala',