f84bc53c8d
* Stub code for http server * can send a response, cannot process body yet * write headers to the response * remove commented code * add simple test + set default http handler * tweak CI + unittest * add missing file * rewrite http::trim in a simple way * doc
35 lines
678 B
C++
35 lines
678 B
C++
/*
|
|
* ws_httpd.cpp
|
|
* Author: Benjamin Sergeant
|
|
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <ixwebsocket/IXHttpServer.h>
|
|
#include <spdlog/spdlog.h>
|
|
|
|
namespace ix
|
|
{
|
|
int ws_httpd_main(int port, const std::string& hostname)
|
|
{
|
|
spdlog::info("Listening on {}:{}", hostname, port);
|
|
|
|
ix::HttpServer server(port, hostname);
|
|
|
|
auto res = server.listen();
|
|
if (!res.first)
|
|
{
|
|
std::cerr << res.second << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
server.start();
|
|
server.wait();
|
|
|
|
return 0;
|
|
}
|
|
}
|