1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

WebServer: Move server configuration into WebServer::Configuration

This moves the configuration of the web server, which currently only
consists of the root path, into a new class, Configuration. Since the
configuration is global and not per client, it is accessed by a
singleton getter.

This change simplifies future extensions of the configurable parameters.
This commit is contained in:
Max Wipfli 2021-06-06 16:51:37 +02:00 committed by Andreas Kling
parent 2d18d3f329
commit e77ca79897
6 changed files with 65 additions and 9 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <WebServer/Configuration.h>
namespace WebServer {
static Configuration* s_configuration = nullptr;
Configuration::Configuration(String root_path)
: m_root_path(move(root_path))
{
VERIFY(!s_configuration);
s_configuration = this;
}
Configuration const& Configuration::the()
{
VERIFY(s_configuration);
return *s_configuration;
}
}