summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authortastytea2020-01-10 13:08:55 +0100
committertastytea2020-01-10 13:08:55 +0100
commita6139b43900c7d580561f93f72be2e51ded5bd42 (patch)
tree56431e8773fa798c7ccba2ae9eb86fdda41982f1 /include
parentf2222151169419fe3afbcdfa3c4ec53627ab1021 (diff)
downloadmastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar
mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.tar.gz
mastodonpp-a6139b43900c7d580561f93f72be2e51ded5bd42.zip
Implement HTTP POST in Connection.
Diffstat (limited to 'include')
-rw-r--r--include/connection.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/connection.hpp b/include/connection.hpp
index 6885931..91a06d7 100644
--- a/include/connection.hpp
+++ b/include/connection.hpp
@@ -125,6 +125,43 @@ public:
}
/*!
+ * @brief Make a HTTP POST call with parameters.
+ *
+ * Example:
+ * @code
+ * auto answer{connection.post(
+ * mastodonpp::API::v1::statuses,
+ * {
+ * {"status", "How is the wheather?"},
+ * {"poll[options]", vector<string_view>{"Nice", "not nice"}},
+ * {"poll[expires_in]", to_string(poll_seconds)}
+ * })};
+ * @endcode
+ *
+ * @param endpoint Endpoint as API::endpoint_type or `std::string_view`.
+ * @param parameters A map of parameters.
+ *
+ *
+ * @since 0.1.0
+ */
+ [[nodiscard]]
+ answer_type post(const endpoint_variant &endpoint,
+ const parametermap &parameters);
+
+ /*!
+ * @brief Make a HTTP POST call.
+ *
+ * @param endpoint Endpoint as API::endpoint_type or `std::string_view`.
+ *
+ * @since 0.1.0
+ */
+ [[nodiscard]]
+ inline answer_type post(const endpoint_variant &endpoint)
+ {
+ return post(endpoint, {});
+ }
+
+ /*!
* @brief Copy new stream contents and delete the “original”.
*
* Note that the last event is not necessarily complete, it could happen
@@ -147,6 +184,8 @@ public:
private:
Instance &_instance;
const string_view _baseuri;
+
+ string endpoint_to_uri(const endpoint_variant &endpoint) const;
};
} // namespace mastodonpp