diff options
author | tastytea | 2020-01-10 13:08:55 +0100 |
---|---|---|
committer | tastytea | 2020-01-10 13:08:55 +0100 |
commit | a6139b43900c7d580561f93f72be2e51ded5bd42 (patch) | |
tree | 56431e8773fa798c7ccba2ae9eb86fdda41982f1 /src | |
parent | f2222151169419fe3afbcdfa3c4ec53627ab1021 (diff) | |
download | mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar.gz mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.zip |
Implement HTTP POST in Connection.
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index 662c333..498384d 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -32,20 +32,28 @@ Connection::Connection(Instance &instance) } } +string Connection::endpoint_to_uri(const endpoint_variant &endpoint) const +{ + if (holds_alternative<API::endpoint_type>(endpoint)) + { + return string(_baseuri) + += API{std::get<API::endpoint_type>(endpoint)}.to_string_view(); + } + return string(_baseuri) += std::get<string_view>(endpoint); +} + answer_type Connection::get(const endpoint_variant &endpoint, const parametermap ¶meters) { - const string uri{[&] - { - if (holds_alternative<API::endpoint_type>(endpoint)) - { - return string(_baseuri) - += API{std::get<API::endpoint_type>(endpoint)}.to_string_view(); - } - return string(_baseuri) += std::get<string_view>(endpoint); - }()}; + return make_request(http_method::GET, + endpoint_to_uri(endpoint), parameters); +} - return make_request(http_method::GET, uri, parameters); +answer_type Connection::post(const endpoint_variant &endpoint, + const parametermap ¶meters) +{ + return make_request(http_method::POST, + endpoint_to_uri(endpoint), parameters); } string Connection::get_new_stream_contents() |