diff --git a/src/App.h b/src/App.h index cd7e927..95ed065 100644 --- a/src/App.h +++ b/src/App.h @@ -533,6 +533,18 @@ public: return std::move(*this); } + /* options, callback, path to unix domain socket */ + TemplatedApp &&listen(int options, MoveOnlyFunction &&handler, std::string path) { + handler(httpContext ? httpContext->listen(path.c_str(), options) : nullptr); + return std::move(*this); + } + + /* callback, path to unix domain socket */ + TemplatedApp &&listen(MoveOnlyFunction &&handler, std::string path) { + handler(httpContext ? httpContext->listen(path.c_str(), 0) : nullptr); + return std::move(*this); + } + TemplatedApp &&run() { uWS::run(); return std::move(*this); diff --git a/src/HttpContext.h b/src/HttpContext.h index 0f8384b..db87486 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -445,6 +445,11 @@ public: us_listen_socket_t *listen(const char *host, int port, int options) { return us_socket_context_listen(SSL, getSocketContext(), host, port, options, sizeof(HttpResponseData)); } + + /* Listen to unix domain socket using this HttpContext */ + us_listen_socket_t *listen(const char *path, int options) { + return us_socket_context_listen_unix(SSL, getSocketContext(), path, options, sizeof(HttpResponseData)); + } }; }