Add support for DELETE requests.
This commit is contained in:
parent
03b097c6a6
commit
5c61d6fd27
|
@ -213,6 +213,32 @@ public:
|
||||||
return put(endpoint, {});
|
return put(endpoint, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Make a HTTP DELETE call with parameters.
|
||||||
|
*
|
||||||
|
* @param endpoint Endpoint as API::endpoint_type or `std::string_view`.
|
||||||
|
* @param parameters A map of parameters.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @since 0.2.0
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
answer_type del(const endpoint_variant &endpoint,
|
||||||
|
const parametermap ¶meters);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Make a HTTP DELETE call.
|
||||||
|
*
|
||||||
|
* @param endpoint Endpoint as API::endpoint_type or `std::string_view`.
|
||||||
|
*
|
||||||
|
* @since 0.2.0
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
inline answer_type del(const endpoint_variant &endpoint)
|
||||||
|
{
|
||||||
|
return del(endpoint, {});
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Copy new stream contents and delete the “original”.
|
* @brief Copy new stream contents and delete the “original”.
|
||||||
*
|
*
|
||||||
|
|
|
@ -75,6 +75,13 @@ answer_type Connection::put(const endpoint_variant &endpoint,
|
||||||
endpoint_to_uri(endpoint), parameters);
|
endpoint_to_uri(endpoint), parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
answer_type Connection::del(const endpoint_variant &endpoint,
|
||||||
|
const parametermap ¶meters)
|
||||||
|
{
|
||||||
|
return make_request(http_method::DELETE,
|
||||||
|
endpoint_to_uri(endpoint), parameters);
|
||||||
|
}
|
||||||
|
|
||||||
string Connection::get_new_stream_contents()
|
string Connection::get_new_stream_contents()
|
||||||
{
|
{
|
||||||
buffer_mutex.lock();
|
buffer_mutex.lock();
|
||||||
|
|
|
@ -139,8 +139,16 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
|
||||||
}
|
}
|
||||||
case http_method::DELETE:
|
case http_method::DELETE:
|
||||||
{
|
{
|
||||||
|
if (!parameters.empty())
|
||||||
|
{
|
||||||
|
curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
|
code = curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
|
||||||
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, "DELETE");
|
code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user