mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +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:
parent
2d18d3f329
commit
e77ca79897
6 changed files with 65 additions and 9 deletions
|
@ -1,15 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Client.h"
|
||||
#include <AK/MappedFile.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/TCPServer.h>
|
||||
#include <WebServer/Client.h>
|
||||
#include <WebServer/Configuration.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -51,6 +53,8 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
WebServer::Configuration configuration(real_root_path);
|
||||
|
||||
Core::EventLoop loop;
|
||||
|
||||
auto server = Core::TCPServer::construct();
|
||||
|
@ -58,7 +62,7 @@ int main(int argc, char** argv)
|
|||
server->on_ready_to_accept = [&] {
|
||||
auto client_socket = server->accept();
|
||||
VERIFY(client_socket);
|
||||
auto client = WebServer::Client::construct(client_socket.release_nonnull(), real_root_path, server);
|
||||
auto client = WebServer::Client::construct(client_socket.release_nonnull(), server);
|
||||
client->start();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue