diff --git a/loader/include/Geode/utils/web.hpp b/loader/include/Geode/utils/web.hpp index 0ad58d45..5cdd12c8 100644 --- a/loader/include/Geode/utils/web.hpp +++ b/loader/include/Geode/utils/web.hpp @@ -112,8 +112,9 @@ namespace geode::utils::web { private: class Impl; + static std::atomic_size_t s_idCounter; std::shared_ptr 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 diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index 3a352edb..5a197270 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -212,7 +212,9 @@ public: } }; -WebRequest::WebRequest() : m_impl(std::make_shared()) {} +std::atomic_size_t WebRequest::s_idCounter = 0; + +WebRequest::WebRequest() : m_impl(std::make_shared()), 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; }