2025-01-13 04:58:58 +10:00
|
|
|
#include <string>
|
2025-01-14 04:53:43 +10:00
|
|
|
#include <map>
|
|
|
|
#include <iterator>
|
|
|
|
#include <regex>
|
|
|
|
|
|
|
|
struct request_info {
|
|
|
|
std::string method, path, params;
|
|
|
|
};
|
2025-01-13 04:58:58 +10:00
|
|
|
|
|
|
|
class RouteHandler {
|
|
|
|
public:
|
|
|
|
static std::string get_response_by_request(const std::string& request);
|
|
|
|
|
|
|
|
protected:
|
2025-01-14 04:53:43 +10:00
|
|
|
static std::string get_string_from_regex(std::string text, std::regex pattern);
|
|
|
|
static struct request_info parse_request(const std::string& request);
|
2025-01-13 04:58:58 +10:00
|
|
|
static std::string format_http_response(std::string status, std::string text);
|
|
|
|
|
|
|
|
private:
|
2025-01-14 04:53:43 +10:00
|
|
|
static std::string get_current_temperature(struct request_info this_request);
|
|
|
|
static std::string get_temperature_by_period(struct request_info this_request);
|
2025-01-13 04:58:58 +10:00
|
|
|
};
|