mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-17 00:34:17 +00:00
Add libhv and test http client
This commit is contained in:
@ -8,9 +8,39 @@ namespace tribufu
|
||||
{
|
||||
this->id = id;
|
||||
this->secret = secret;
|
||||
this->http = hv::HttpClient();
|
||||
}
|
||||
|
||||
TribufuClient::~TribufuClient()
|
||||
{
|
||||
}
|
||||
|
||||
void TribufuClient::get_token()
|
||||
{
|
||||
try
|
||||
{
|
||||
const char *base_url = "http://localhost:5000";
|
||||
|
||||
HttpRequest req;
|
||||
req.SetMethod("POST");
|
||||
req.SetUrl(base_url);
|
||||
|
||||
HttpResponse resp;
|
||||
|
||||
int ret = this->http.send(&req, &resp);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
std::cout << "request_failed" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "request_success" << std::endl;
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
std::cout << "exception" << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user