#ifndef APP_H #define APP_H /* An app is a convenience wrapper of some of the most used fuctionalities and allows a * builder-pattern kind of init. Apps operate on the implicit thread local Loop */ #include "HttpContext.h" #include "HttpResponse.h" namespace uWS { template struct TemplatedApp { private: HttpContext *httpContext; public: ~TemplatedApp() { } TemplatedApp(const TemplatedApp &other) { httpContext = other.httpContext; } TemplatedApp(us_ssl_socket_context_options sslOptions = {}) { httpContext = uWS::HttpContext::create(uWS::Loop::defaultLoop(), &sslOptions); } TemplatedApp &get(std::string pattern, std::function *, HttpRequest *)> handler) { httpContext->onGet(pattern, handler); return *this; } TemplatedApp &unhandled(std::function *, HttpRequest *)> handler) { httpContext->onUnhandled(handler); return *this; } TemplatedApp &listen(int port, std::function handler) { handler(httpContext->listen(nullptr, port, 0)); return *this; } TemplatedApp &run() { uWS::run(); return *this; } }; typedef TemplatedApp App; typedef TemplatedApp SSLApp; } #endif // APP_H