mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-26 01:18:01 -05:00
Merge pull request #1040 from SMJSGaming/main
Added IDs to web request to prevent incompatibilities between web mods
This commit is contained in:
commit
00e191accb
2 changed files with 16 additions and 2 deletions
|
@ -112,8 +112,9 @@ namespace geode::utils::web {
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
|
|
||||||
|
static std::atomic_size_t s_idCounter;
|
||||||
std::shared_ptr<Impl> m_impl;
|
std::shared_ptr<Impl> m_impl;
|
||||||
|
const size_t m_id;
|
||||||
public:
|
public:
|
||||||
WebRequest();
|
WebRequest();
|
||||||
~WebRequest();
|
~WebRequest();
|
||||||
|
@ -253,6 +254,13 @@ namespace geode::utils::web {
|
||||||
*/
|
*/
|
||||||
WebRequest& bodyJSON(matjson::Value const& json);
|
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
|
* Gets the request method as a string
|
||||||
|
|
|
@ -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() {}
|
WebRequest::~WebRequest() {}
|
||||||
|
|
||||||
// Encodes a url param
|
// Encodes a url param
|
||||||
|
@ -584,6 +586,10 @@ WebRequest& WebRequest::bodyJSON(matjson::Value const& json) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t WebRequest::getID() const {
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
std::string WebRequest::getMethod() const {
|
std::string WebRequest::getMethod() const {
|
||||||
return m_impl->m_method;
|
return m_impl->m_method;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue