Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
application::helper::CurlWrapper Class Reference

Minimalist C++ wrapper of easy (blocking interface) CURL library for RESTful communication. More...

#include <curl_wrapper.h>

Public Member Functions

 CurlWrapper (std::string vccApiKey, std::string bearerToken)
 Constructor. More...
 
bool TryExecute (std::string url, std::string *response)
 Try to execute a RESTful GET request. More...
 

Detailed Description

Minimalist C++ wrapper of easy (blocking interface) CURL library for RESTful communication.

Constructor & Destructor Documentation

◆ CurlWrapper()

application::helper::CurlWrapper::CurlWrapper ( std::string  vccApiKey,
std::string  bearerToken 
)

Constructor.

Parameters
vccApiKeyVCC API key
bearerTokenOAuth 2.0 bearer token
Exceptions
std::runtime_errorThrows when the CURL handler creation failed.

Member Function Documentation

◆ TryExecute()

bool application::helper::CurlWrapper::TryExecute ( std::string  url,
std::string *  response 
)

Try to execute a RESTful GET request.

Parameters
[in]urlREST API request URL
[out]responseREST API server response in JSON format excluding the header
Returns
True if the request is executed successfully (even with not 200 HTTP code); otherwise false
Note
In case of getting 'false' as the return value, the 'response' content should be discared.
Remarks
The function call is blocking.