-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e431aa
commit 41d3d4b
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
REACT-CPP-CURL | ||
============== | ||
|
||
C++ asynchronous cURL wrapper on top of the REACT-CPP library. Uses lambdas and callbacks to return query results. | ||
|
||
Request class | ||
============= | ||
|
||
The React::Curl::Request class is used to build your requests and execute them. | ||
|
||
``` | ||
#include <reactcpp/curl.h> | ||
#include <iostream> | ||
int main() | ||
{ | ||
// create an event loop | ||
React::MainLoop loop; | ||
React::Curl::Request request(&loop, "http://example.org"); | ||
request.execute().onSuccess([](React::Curl::Result &&result) { | ||
std::cout << "Callback" << std::endl; | ||
std::cout << result.body() << std::endl; | ||
std::cout << "Headers" << std::endl; | ||
std::cout << result.headers() << std::endl; | ||
}).onFailure([](const char *error) { | ||
std::cerr << "Error: " << error << std::endl; | ||
}); | ||
loop.run(); | ||
} | ||
``` | ||
|
||
As you can see you'll get a Result object in your success callback which allows you to access the body and the headers of the result. |