mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
More refactoring and bug fixes
- Added `libhttp` and `librest_api` targets to CMakeLists.txt - Added examples for `libhttp` and `librest_api` in examples directory - Added `cache` and `add` commands - Added documentation for `libhttp` and `librest_api` - Added all available HTTP response codes to REST API - Changed how `bin/compile.sh` works (must supply args to build)
This commit is contained in:
parent
5a73651ad1
commit
8b1f1374d8
23 changed files with 575 additions and 164 deletions
15
examples/http/README.md
Normal file
15
examples/http/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# GDPM HTTP Example
|
||||
|
||||
This is an example showing how to use the GDPM HTTP library to download files. The library uses RapidJSON to get results.
|
||||
|
||||
|
||||
Here is a quick snippet to get started:
|
||||
```c++
|
||||
// Get a full list of assets
|
||||
rest_api::context context = rest_api::make_context();
|
||||
rapidjson::Document doc = http::get_asset_list(
|
||||
"https://godotengine.org/asset-library/api",
|
||||
context
|
||||
)
|
||||
// ... parse the rapidjson::Document
|
||||
```
|
||||
9
examples/http/main.cpp
Normal file
9
examples/http/main.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/*! Example using the `libgdpm-http` library
|
||||
*/
|
||||
|
||||
#include "http.hpp"
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
return 0;
|
||||
}
|
||||
26
examples/rest_api/README.md
Normal file
26
examples/rest_api/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# GDPM Rest API Example
|
||||
|
||||
This is an example showing how to use the REST API designed to query the Godot Asset library in C++. It is built using the `libcurl` library.
|
||||
|
||||
Here is a snippet making a HTTP get and post request.
|
||||
|
||||
```c++
|
||||
using string = std::string;
|
||||
using headers_t = std::unordered_map<string, string>;
|
||||
|
||||
std::string url = "www.example.com";
|
||||
http::response r_get = http::request_get(url)
|
||||
if(r_get.response_code == http::response_code::OK){
|
||||
// ...do something...
|
||||
}
|
||||
|
||||
http::request_params params;
|
||||
params.headers = {
|
||||
{"user-agent", "firefox"},
|
||||
{"content-type", "application/json"}
|
||||
}
|
||||
http::response r_post = http::request_post(url, params);
|
||||
if(r_post.response_code == http::response_code::OK){
|
||||
// ...do something...
|
||||
}
|
||||
```
|
||||
8
examples/rest_api/main.cpp
Normal file
8
examples/rest_api/main.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/*! Example using the `libgdpm-restapi` library */
|
||||
|
||||
#include "rest_api.hpp"
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue