mastodonpp  0.0.0
Public Member Functions | List of all members
mastodonpp::Connection Class Reference

Represents a connection to an instance. Used for requests. More...

#include <mastodonpp/connection.hpp>

Inheritance diagram for mastodonpp::Connection:
mastodonpp::CURLWrapper

Public Member Functions

 Connection (Instance &instance)
 Construct a new Connection object. More...
 
answer_type get (const API::endpoint_type &endpoint)
 Make a HTTP GET call. More...
 
answer_type get (const string_view &endpoint)
 Make a HTTP GET call. More...
 
- Public Member Functions inherited from mastodonpp::CURLWrapper
 CURLWrapper ()
 Initializes curl and sets up connection. More...
 
 CURLWrapper (const CURLWrapper &other)=default
 Copy constructor. More...
 
 CURLWrapper (CURLWrapper &&other) noexcept=default
 Move constructor. More...
 
virtual ~CURLWrapper () noexcept
 Cleans up curl and connection. More...
 
CURLWrapperoperator= (const CURLWrapper &other)=default
 Copy assignment operator. More...
 
CURLWrapperoperator= (CURLWrapper &&other) noexcept=default
 Move assignment operator. More...
 
CURL * get_curl_easy_handle ()
 Returns pointer to the CURL easy handle. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mastodonpp::CURLWrapper
answer_type make_request (const http_method &method, const string_view &uri)
 Make a request. More...
 

Detailed Description

Represents a connection to an instance. Used for requests.

Since
0.1.0

Constructor & Destructor Documentation

◆ Connection()

mastodonpp::Connection::Connection ( Instance instance)
explicit

Construct a new Connection object.

Parameters
instanceAn Instance with the access data.
Since
0.1.0
23  : _instance{instance}
24  , _baseuri{instance.get_baseuri()}
25 {}

Member Function Documentation

◆ get() [1/2]

answer_type mastodonpp::Connection::get ( const API::endpoint_type endpoint)

Make a HTTP GET call.

Parameters
endpointEndpoint as API::endpoint_type, for example: mastodonpp::API::v1::instance.
Since
0.1.0
28 {
29  return make_request(
30  http_method::GET,
31  string(_baseuri).append(API{endpoint}.to_string_view()));
32 }

◆ get() [2/2]

answer_type mastodonpp::Connection::get ( const string_view &  endpoint)

Make a HTTP GET call.

Parameters
endpointEndpoint as string, for example: "/api/v1/instance".
Since
0.1.0
35 {
36  return make_request(http_method::GET, string(_baseuri).append(endpoint));
37 }

The documentation for this class was generated from the following files:
mastodonpp::CURLWrapper::make_request
answer_type make_request(const http_method &method, const string_view &uri)
Make a request.
Definition: curl_wrapper.cpp:60