44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef __APPLICATION_H__
|
|
#define __APPLICATION_H__
|
|
|
|
#include "Router/matches.hpp"
|
|
#include <boost/beast/http/string_body.hpp>
|
|
|
|
namespace Core {
|
|
class IoContext;
|
|
} // namespace Core
|
|
|
|
namespace boost {
|
|
namespace asio {
|
|
class io_context;
|
|
}
|
|
} // namespace boost
|
|
|
|
namespace Danki {
|
|
|
|
class ApplicationPrivate;
|
|
class Settings;
|
|
class HttpSession;
|
|
class SignalServer;
|
|
|
|
class Application : public std::enable_shared_from_this<Application> {
|
|
public:
|
|
using Request = boost::beast::http::request<boost::beast::http::string_body>;
|
|
using RequestHandler = std::function<void(HttpSession &, const Request &, const boost::urls::matches &)>;
|
|
Application();
|
|
boost::asio::io_context &ioContext();
|
|
void insertUrl(std::string_view url, RequestHandler &&handler);
|
|
int exec();
|
|
void startAcceptHttpConnections(const std::string &address, uint16_t port);
|
|
|
|
protected:
|
|
void asyncAcceptHttpConnections();
|
|
|
|
private:
|
|
ApplicationPrivate *m_d = nullptr;
|
|
std::shared_ptr<Settings> m_settings;
|
|
std::shared_ptr<Core::IoContext> m_ioContext;
|
|
std::shared_ptr<SignalServer> m_signalServer;
|
|
};
|
|
} // namespace Danki
|
|
#endif // __APPLICATION_H__
|