2025-01-15 19:48:49 +00:00
|
|
|
#ifndef __CHATWEBAPI_H__
|
|
|
|
#define __CHATWEBAPI_H__
|
|
|
|
#include <string>
|
|
|
|
#include <functional>
|
2025-01-02 06:45:53 +00:00
|
|
|
|
2025-01-02 22:11:45 +00:00
|
|
|
#include "mongoose.h"
|
2025-01-15 19:48:49 +00:00
|
|
|
#include "eHTTPStatusCode.h"
|
|
|
|
|
|
|
|
enum class eHTTPMethod;
|
2025-01-02 06:45:53 +00:00
|
|
|
|
2025-01-03 02:42:50 +00:00
|
|
|
typedef struct mg_mgr mg_mgr;
|
|
|
|
|
2025-01-15 19:48:49 +00:00
|
|
|
struct HTTPReply {
|
|
|
|
eHTTPStatusCode status = eHTTPStatusCode::NOT_FOUND;
|
|
|
|
std::string message = "{\"error\":\"Not Found\"}";
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WebAPIHTTPRoute {
|
|
|
|
std::string path;
|
|
|
|
eHTTPMethod method;
|
|
|
|
std::function<void(HTTPReply&, const std::string&)> handle;
|
|
|
|
};
|
|
|
|
|
2025-01-02 06:45:53 +00:00
|
|
|
class ChatWebAPI {
|
|
|
|
public:
|
2025-01-02 22:11:45 +00:00
|
|
|
ChatWebAPI();
|
2025-01-02 06:45:53 +00:00
|
|
|
~ChatWebAPI();
|
2025-01-02 22:11:45 +00:00
|
|
|
void ReceiveRequests();
|
2025-01-15 19:48:49 +00:00
|
|
|
void RegisterHTTPRoutes(WebAPIHTTPRoute route);
|
|
|
|
bool Startup();
|
2025-01-02 06:45:53 +00:00
|
|
|
private:
|
2025-01-03 02:42:50 +00:00
|
|
|
mg_mgr mgr;
|
2025-01-06 07:23:29 +00:00
|
|
|
|
2025-01-02 06:45:53 +00:00
|
|
|
};
|
|
|
|
|
2025-01-15 19:48:49 +00:00
|
|
|
#endif // __CHATWEBAPI_H__
|