summaryrefslogtreecommitdiffhomepage
path: root/webserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'webserver.cpp')
-rw-r--r--webserver.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/webserver.cpp b/webserver.cpp
index 4b6a89c..b079707 100644
--- a/webserver.cpp
+++ b/webserver.cpp
@@ -1,6 +1,40 @@
+#include "config.h"
#include "http.h"
+#include <exception>
+#include <iostream>
+#include <string>
+
+using namespace std::string_literals;
+
+void usage()
+{
+ std::cout << "usage: webserver [-c <configuration-filename>]" << std::endl;
+}
+
int main(int argc, char* argv[])
{
- return http_server(argc, argv);
+ std::string config_filename;
+
+ if (!(argc == 1 || argc == 3)) {
+ usage();
+ return 1;
+ }
+
+ if (argc == 3) {
+ if (argv[1] != "-c"s) {
+ usage();
+ return 1;
+ }
+
+ config_filename = argv[2];
+ }
+
+ try {
+ Config config{config_filename};
+ return http_server(argc, argv);
+ } catch (const std::exception& ex) {
+ std::cout << "Error: " << ex.what() << std::endl;
+ return 1;
+ }
}