瀏覽代碼

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.
Thomas Keppler 2 年之前
父節點
當前提交
1d6528b94b
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      Userland/Services/WebServer/main.cpp

+ 7 - 5
Userland/Services/WebServer/main.cpp

@@ -1,10 +1,12 @@
 /*
  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  * Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
+ * Copyright (c) 2022, Thomas Keppler <serenity@tkeppler.de>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include <AK/String.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/EventLoop.h>
 #include <LibCore/File.h>
@@ -20,15 +22,15 @@
 
 ErrorOr<int> 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");