WebExpress 2.0.0‑alpha – The End of config.xml

In modern software development with .NET the way we configure applications has changed fundamentally. While XML-based configuration files like a config.xml were the undisputed standard in the classic framework era the stage today belongs to cross-platform and cloud-native approaches. For a lightweight web server framework like WebExpress the switch to the modern appsettings.json offers an excellent opportunity to further increase performance while drastically simplifying handling for developers. The theoretical basis for this change is founded on the modern .NET Configuration Provider model which no longer views settings as rigid documents but as a flexible key-value store that can be dynamically fed from a wide variety of sources.


The greatest advantage of this JSON-based configuration lies in its native and seamless integration into modern container environments like Docker. When WebExpress runs in a Docker container developers often need to control individual parameters such as port assignments paths or plugin options from the outside. With a classic XML file this requires cumbersome additional code in the C# program which manually queries the system for environment variables and overrides the values. The appsettings.json model solves this challenge completely automatically through its hierarchical structure. By defining environment variables in a Docker Compose file the .NET runtime system overrides the values from the JSON file in memory without a single line in the core of WebExpress needing to be adjusted. Furthermore JSON offers native type safety through the so-called Options Pattern. Instead of having to laboriously convert XML text into integers or booleans in the code the JSON structure can be mapped directly into strongly typed C# classes with a single command. Additionally .NET features a built-in capability that detects changes to the file during runtime without a server restart and reads them back in directly.

The path to practical implementation in the WebExpress repository on the develop branch is very straightforward thanks to the modern .NET architecture. The existing webexpress.config.xml with its attributes for logging endpoints and Kestrel limits can be transferred one to one into a clear webexpress.json file. When a plugin is loaded in the system its specific configuration file is also loaded automatically. During the deployment of a plugin its JSON file is simply copied into the central settings folder where all other configurations are gathered. In the C# source code of WebExpress the Configuration Builder is integrated which first loads the central webexpress.json at application startup and then dynamically searches the settings folder for all other plugin files to inject them into the shared configuration tree. By binding these centrally managed sections to simple C# classes the entire old XML parsing code of the framework is eliminated which massively increases code maintainability. For WebExpress this step represents a giant leap forward since the framework is prepared for the requirements of modern DevOps pipelines simple Docker deployments and lean runtime environments.

To bring this modernization to the develop branch quickly and successfully the entire WebExpress community is called upon to actively contribute. Since this is a fundamental change to the infrastructure all developers testers and architecture enthusiasts are invited to participate in the transformation. Whether it is writing conversion scripts for existing installations testing or rewriting the existing plugins to the new JSON format every contribution brings the project a big step closer. Interested parties can contribute their own proposals directly in the GitHub repository or open a pull request directly to jointly usher in the next era of WebExpress.

Comments

Popular posts from this blog

WebExpress 0.0.10-alpha – A Step Back for Reflection

WebExpress 0.0.10-alpha – The REST APIs as the Foundation of the Table Architecture

WebExpress 0.0.8-alpha – Completion of the Development Guide for WebExpress