refactor again

This commit is contained in:
Aaron Kimbre
2025-01-15 13:48:49 -06:00
parent 72ae55981b
commit 5b8fe2cba0
3 changed files with 106 additions and 101 deletions

View File

@@ -1,29 +1,36 @@
#ifndef CHATWEBAPI_H
#define CHATWEBAPI_H
#ifndef __CHATWEBAPI_H__
#define __CHATWEBAPI_H__
#include <string>
#include <functional>
#include "mongoose.h"
#include "eHTTPStatusCode.h"
enum class eHTTPMethod;
typedef struct mg_mgr mg_mgr;
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;
};
class ChatWebAPI {
public:
ChatWebAPI();
~ChatWebAPI();
void ReceiveRequests();
void Listen();
enum class eRoute {
// GET
PLAYERS,
TEAMS,
// POST
ANNOUNCE,
// INVALID
INVALID
};
void RegisterHTTPRoutes(WebAPIHTTPRoute route);
bool Startup();
private:
mg_mgr mgr;
};
#endif
#endif // __CHATWEBAPI_H__