summaryrefslogtreecommitdiffstats
path: root/src/connection.cpp
Commit message (Collapse)AuthorAge
* Rename buffer_mutex → _buffer_mutex.tastytea2020-01-28
|
* Mark buffer variables const.tastytea2020-01-20
|
* Simplify connection setup.tastytea2020-01-12
| | | | By adding CURLWrapper::setup_connection_properties.
* Add Instance::set_cainfo().tastytea2020-01-12
|
* Made code in Connection::get_new_events() clearer.tastytea2020-01-11
|
* Add support for DELETE requests.tastytea2020-01-11
|
* Add HTTP methods PATCH and PUT.tastytea2020-01-11
|
* Send the access token.tastytea2020-01-10
|
* Implement HTTP POST in Connection.tastytea2020-01-10
|
* Add baseurl to uri if endpoint is string_view.tastytea2020-01-09
|
* Add get_new_events().tastytea2020-01-09
| | | | A more comfortable way to consume stream events.
* Move set_proxy() to Instance.tastytea2020-01-09
|
* Add streaming support.tastytea2020-01-08
|
* Replace append with +=.tastytea2020-01-08
|
* Add set_proxy().tastytea2020-01-08
|
* Replace string with string_view where possible.tastytea2020-01-08
|
* Add support for parameters (GET).tastytea2020-01-08
|
* Make _endpoint_map static.tastytea2020-01-05
|
* Only construct 1 API per Connection.tastytea2020-01-05
|
* Optimize request-flow. 😃tastytea2020-01-05
|
* Renamed “Request” to “Connection”.tastytea2020-01-05
It will be used not for only one request, but for all requests to an instance.
an class="w"> std::cerr; using std::endl; using std::to_string; using std::string_view; using std::vector; int main(int argc, char *argv[]) { const vector<string_view> args(argv, argv + argc); if (args.size() <= 1) { cerr << "Usage: " << args[0] << " <instance hostname>\n"; return 1; } try { // Initialize an Instance. masto::Instance instance{args[1], {}}; // Get maximum allowed characters per post. const auto max_chars{instance.get_max_chars()}; cout << "Maximum characters per post: " << max_chars << "\n\n"; // Initialize a Connection. masto::Connection connection{instance}; // Get information about the instance. masto::answer_type answer{connection.get(masto::API::v1::instance)}; if (answer) { cout << answer << endl; } else { if (answer.curl_error_code == 0) { // If it is no libcurl error, it must be an HTTP error. cerr << "HTTP status: " << answer.http_status << endl; } else { // Network errors like “Couldn't resolve host.”. cerr << "libcurl error " << to_string(answer.curl_error_code) << ": " << answer.error_message << endl; } } } catch (const masto::CURLException &e) { // Only libcurl errors that are not network errors will be thrown. // There went probably something wrong with the initialization. cerr << e.what() << endl; } return 0; }