Added IDs to web request to prevent incompatibilities between web mods

This commit is contained in:
SMJSGaming 2024-08-13 09:05:59 +02:00
parent caeef8f4a4
commit a5bbf6a40c
2 changed files with 16 additions and 2 deletions

View file

@ -112,8 +112,9 @@ namespace geode::utils::web {
private:
class Impl;
static size_t m_idCounter;
std::shared_ptr<Impl> m_impl;
const size_t m_id;
public:
WebRequest();
~WebRequest();
@ -253,6 +254,13 @@ namespace geode::utils::web {
*/
WebRequest& bodyJSON(matjson::Value const& json);
/**
* Gets the unique request ID
*
* @return size_t
*/
size_t getID() const;
/**
* Gets the request method as a string

View file

@ -212,7 +212,9 @@ public:
}
};
WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()) {}
size_t WebRequest::m_idCounter = 0;
WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()), m_id(WebRequest::m_idCounter++) {}
WebRequest::~WebRequest() {}
// Encodes a url param
@ -584,6 +586,10 @@ WebRequest& WebRequest::bodyJSON(matjson::Value const& json) {
return *this;
}
size_t WebRequest::getID() const {
return m_id;
}
std::string WebRequest::getMethod() const {
return m_impl->m_method;
}