DarkflameServer/dChatServer/ChatWebAPI.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
661 B
C
Raw Normal View History

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
#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:
ChatWebAPI();
2025-01-02 06:45:53 +00:00
~ChatWebAPI();
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-02 06:45:53 +00:00
};
2025-01-15 19:48:49 +00:00
#endif // __CHATWEBAPI_H__