Skip to content
JUCE module for making HTTP requests to REST API's
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Source
Doxyfile
LICENSE
README.md
juce_module_info
rest_request.cpp
rest_request.h
rest_request.mm

README.md

RestRequest

JUCE module for making HTTP requests to REST API's

Example Usage

First declare your class instance e.g. as a member variable:

adamski::RestRequest request;

Then in your constructor add any headers you will need across different requests e.g.:

request.header ("Content-Type", "application/json");
request.header ("Authorization", "Basic " + Base64::toBase64 ("username:password"));

Example GET request:

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:

adamski::RestRequest::Response response = request.post ("registry/_find")
        .field ("selector", searchString)
        .execute();

Example PUT request with chained field methods:

adamski::RestRequest::Response response = request.put ("_users/" + id)
        .field ("type", "user")
        .field ("name", username)
        .field ("email", email)
        .field ("roles", Array<var>({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

You can’t perform that action at this time.