Feature #9939

Consider exposing configuration as an API

Added by Roel Standaert 11 months ago. Updated 5 months ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


At the moment we read configuration from XML files (wt_config.xml), and wthttp command line arguments.

These are kept in classes that are not part of the public API.

We often get questions asking how to retrieve these configuration options in code, however, where the answer is a rather unsatisfying "if there's no WServer function that allows you to check it you'll have to parse the XML or command line arguments yourself".

Often enough there's the need to set those configuration options in code as well, for example when the user has their own configuration system for the rest of their software, where the answer has been "you'll have to write those out as a string or a file".

I think we should have a configuration class that is exposed in the API, that has a function to read it from XML, but also allows to set the options in plain old C++ code. We could similarly expose one for wthttp specifically. This one would only be usable if the user is using wthttp, but it doesn't really make sense to use anything else.


Updated by Roel Standaert 5 months ago

The public interface of the Configuration class would probably be something like this:

class Configuration {
  //! Create default configuration

   * \brief Create configuration from XML file
   * Equivalent to:
   * ```cpp
   * Configuration configuration;
   * configuration.loadXml(xmlFile, applicationPath);
   * ```
   explicit Configuration(const std::string& xmlFile, const std::string& applicationPath);

   //! Load configuration from XML file
   void loadXml(const std::string& xmlFile, const std::string& applicationPath);

   // In the future, we may perhaps have a function to write the configuration to XML

   // Getters and setters for all of the various configuration options

Also available in: Atom PDF