Added remove methods to the web API

This commit is contained in:
SMJSGaming 2024-07-27 19:53:07 +02:00
parent 29dba46f1e
commit 72586f780d
2 changed files with 12 additions and 0 deletions

View file

@ -125,11 +125,13 @@ namespace geode::utils::web {
WebTask patch(std::string_view url);
WebRequest& header(std::string_view name, std::string_view value);
WebRequest& removeHeader(std::string_view name);
WebRequest& param(std::string_view name, std::string_view value);
template <std::integral T>
WebRequest& param(std::string_view name, T value) {
return this->param(name, std::to_string(value));
}
WebRequest& removeParam(std::string_view name);
/**
* Sets the request's user agent.

View file

@ -505,11 +505,21 @@ WebRequest& WebRequest::header(std::string_view name, std::string_view value) {
return *this;
}
WebRequest& WebRequest::removeHeader(std::string_view name) {
m_impl->m_headers.erase(std::string(name));
return *this;
}
WebRequest& WebRequest::param(std::string_view name, std::string_view value) {
m_impl->m_urlParameters.insert_or_assign(std::string(name), std::string(value));
return *this;
}
WebRequest& WebRequest::removeParam(std::string_view name) {
m_impl->m_urlParameters.erase(std::string(name));
return *this;
}
WebRequest& WebRequest::userAgent(std::string_view name) {
m_impl->m_userAgent = name;
return *this;