Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamski/RestRequest
JUCE module for making HTTP requests to REST API's
https://github.com/adamski/RestRequest
http-requests juce rest-api restrequest
Last synced: 3 months ago
JSON representation
JUCE module for making HTTP requests to REST API's
- Host: GitHub
- URL: https://github.com/adamski/RestRequest
- Owner: adamski
- License: mit
- Created: 2015-12-18T23:41:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-15T14:10:57.000Z (almost 4 years ago)
- Last Synced: 2024-05-13T07:32:17.750Z (6 months ago)
- Topics: http-requests, juce, rest-api, restrequest
- Language: C++
- Size: 10.7 KB
- Stars: 62
- Watchers: 6
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-juce - RestRequest
README
# RestRequest
JUCE module for making HTTP requests to REST API's### Example Usage
First declare your class instance e.g. as a member variable:
```cpp
adamski::RestRequest request;
```Then in your constructor add any headers you will need across different requests e.g.:
```cpp
request.header ("Content-Type", "application/json");
request.header ("Authorization", "Basic " + Base64::toBase64 ("username:password"));
```Example `GET` request:
```cpp
adamski::RestRequest::Response response = request.get ("registry/_design/module-views/_view/all-modules")
.execute();// Example response debugging
DBG (response.bodyAsString);
DBG (response.result.getErrorMessage());
for (auto key : response.headers.getAllKeys())
{
DBG (key << ": " << response.headers.getValue(key, "n/a"));
}
```Example `POST` request:
```cpp
adamski::RestRequest::Response response = request.post ("registry/_find")
.field ("selector", searchString)
.execute();
```Example `PUT` request with chained field methods:
```cpp
adamski::RestRequest::Response response = request.put ("_users/" + id)
.field ("type", "user")
.field ("name", username)
.field ("email", email)
.field ("roles", Array({var("publisher")}))
.field ("password_sha", stringToSHA1 (password + salt))
.field ("salt", salt)
.execute();```
If you need to encode or decode strings with SHA1 I made a JUCE module out of an open source library called smallsha1: https://github.com/adamski/smallsha1