summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortastytea2020-01-10 13:08:55 +0100
committertastytea2020-01-10 13:08:55 +0100
commita6139b43900c7d580561f93f72be2e51ded5bd42 (patch)
tree56431e8773fa798c7ccba2ae9eb86fdda41982f1 /src
parentf2222151169419fe3afbcdfa3c4ec53627ab1021 (diff)
downloadmastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar
mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar.gz
mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.zip
Implement HTTP POST in Connection.
Diffstat (limited to 'src')
-rw-r--r--src/connection.cpp28
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 &parameters)
{
- 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 &parameters)
+{
+ return make_request(http_method::POST,
+ endpoint_to_uri(endpoint), parameters);
}
string Connection::get_new_stream_contents()