Files
sniper/include/HttpClient.hpp
T
2026-08-09 16:51:01 -05:00

28 lines
962 B
C++

#pragma once
#include <string>
#include <map>
struct HttpResponse {
long status = 0;
std::string body;
bool ok() const { return status >= 200 && status < 300; }
};
// Minimal libcurl wrapper used for both scraping (GET) and talking to the
// Discord REST API / webhooks (POST json). Kept tiny and dependency-light
// rather than reusing a full framework.
class HttpClient {
public:
static void globalInit(); // call once at process start
static void globalCleanup();
static HttpResponse get(const std::string& url,
const std::map<std::string, std::string>& headers = {},
long timeout_seconds = 30);
static HttpResponse postJson(const std::string& url,
const std::string& json_body,
const std::map<std::string, std::string>& headers = {},
long timeout_seconds = 15);
};