Merge pull request #1040 from SMJSGaming/main

Added IDs to web request to prevent incompatibilities between web mods
This commit is contained in:
HJfod 2024-08-13 11:35:49 +03:00 committed by GitHub
commit 00e191accb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -112,8 +112,9 @@ namespace geode::utils::web {
private:
class Impl;
static std::atomic_size_t s_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>()) {}
std::atomic_size_t WebRequest::s_idCounter = 0;
WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()), m_id(WebRequest::s_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;
}