From 1d6528b94b258b031dd5a59287fed6c09bda697f Mon Sep 17 00:00:00 2001 From: Thomas Keppler Date: Tue, 20 Dec 2022 15:47:25 +0100 Subject: [PATCH] WebServer: Use new String type for default option values We've also pulled out the default root path instead of folding it in with the receiving variables, so that it's uniform across all options with default values. --- Userland/Services/WebServer/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Userland/Services/WebServer/main.cpp b/Userland/Services/WebServer/main.cpp index d51f683f16..dc6c6f3856 100644 --- a/Userland/Services/WebServer/main.cpp +++ b/Userland/Services/WebServer/main.cpp @@ -1,10 +1,12 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Max Wipfli + * Copyright (c) 2022, Thomas Keppler * * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -20,15 +22,15 @@ ErrorOr serenity_main(Main::Arguments arguments) { - DeprecatedString default_listen_address = "0.0.0.0"; - u16 default_port = 8000; - DeprecatedString default_document_root_path = "/www"; + static auto const default_listen_address = TRY(String::from_utf8("0.0.0.0"sv)); + static auto const default_port = 8000; + static auto const default_document_root_path = TRY(String::from_utf8("/www"sv)); - DeprecatedString listen_address = default_listen_address; + DeprecatedString listen_address = default_listen_address.to_deprecated_string(); int port = default_port; DeprecatedString username; DeprecatedString password; - DeprecatedString document_root_path = default_document_root_path; + DeprecatedString document_root_path = default_document_root_path.to_deprecated_string(); Core::ArgsParser args_parser; args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");