-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttpServer.cxx
59 lines (43 loc) · 1.46 KB
/
httpServer.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <boost/network/protocol/http/server.hpp>
#include <boost/network/utils/thread_pool.hpp>
#include <boost/program_options.hpp>
#include <sstream>
#include <iostream>
#include "handlers.hxx"
#include "synchronicity.hxx"
#include "runServer.hxx"
namespace http = boost::network::http;
namespace po = boost::program_options;
//typedef http::server<SyncHttpHandler> SyncHttpServer;
//typedef http::async_server<ASyncHttpHandler> ASyncHttpServer;
int main(int argc, char * argv[])
{
std::string port;
Synchronicity synchronicity;
Handlers handler;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "display this message")
("port,p", po::value<std::string>(&port)->required(), "port to listen on")
("async", po::value<Synchronicity>(&synchronicity)->default_value(Synchronicity::SYNCHRONE), "synchrous or asynchronous server")
("handler", po::value<Handlers>(&handler)->default_value(Handlers::ECHO), "How to handle requests?")
;
try {
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
if(vm.count("help")) {
desc.print(std::cout);
exit(0);
}
po::notify(vm);
} catch (std::exception& ex) {
std::cerr << "Missing required option: \n";
std::cerr << ex.what() << "\n";
std::cerr << "Useage:\n";
desc.print(std::cerr);
exit(1);
}
runServer(synchronicity, handler, port);
}
/* vim:set tabstop=4 shiftwidth=4 fo=cqwan autoindent : */
/* makeprg=make\ -C\ ~/tmp/build-try-https */