Add functions to accept listening options (#879)

This commit is contained in:
Mike Seese
2019-04-17 20:38:25 +02:00
committed by Alex Hultman
parent 31574ec63a
commit caeaade092
+12
View File
@@ -284,12 +284,24 @@ public:
return std::move(*this);
}
/* Host, port, options, callback */
TemplatedApp &&listen(std::string host, int port, int options, fu2::unique_function<void(us_listen_socket *)> &&handler) {
handler(httpContext->listen(host.c_str(), port, options));
return std::move(*this);
}
/* Port, callback */
TemplatedApp &&listen(int port, fu2::unique_function<void(us_listen_socket *)> &&handler) {
handler(httpContext->listen(nullptr, port, 0));
return std::move(*this);
}
/* Port, options, callback */
TemplatedApp &&listen(int port, int options, fu2::unique_function<void(us_listen_socket *)> &&handler) {
handler(httpContext->listen(nullptr, port, options));
return std::move(*this);
}
TemplatedApp &&run() {
uWS::run();
return std::move(*this);