1010#include " LogManager.h"
1111#include " httplib.h"
1212
13- std::size_t WriteMemoryCallback (const char * in, std::size_t size, std::size_t num, std::string* out)
14- {
15- const std::size_t totalBytes (size * num);
16- out->append (in, totalBytes);
17- return totalBytes;
18- }
19-
2013long APIRequest (std::string method, std::string location, std::string URI, json* request_data = nullptr , json* response_data = nullptr )
2114{
22- const std::string url (" http://" +location);
15+ /* -------------------------------------------------------------*\
16+ | Append http:// to the location field to create the URL |
17+ \*-------------------------------------------------------------*/
18+ const std::string url (" http://" + location);
2319
2420 /* -------------------------------------------------------------*\
2521 | Create httplib Client and variables to hold result |
@@ -28,6 +24,9 @@ long APIRequest(std::string method, std::string location, std::string URI, json*
2824 int status = 0 ;
2925 std::string body = " " ;
3026
27+ /* -------------------------------------------------------------*\
28+ | Perform the appropriate call for the given method |
29+ \*-------------------------------------------------------------*/
3130 if (method == " GET" )
3231 {
3332 httplib::Result result = client.Get (URI.c_str ());
@@ -67,8 +66,9 @@ long APIRequest(std::string method, std::string location, std::string URI, json*
6766 body = result->body ;
6867 }
6968
70- LOG_DEBUG (" [Nanoleaf] Result %d %s" , status, body.c_str ());
71-
69+ /* -------------------------------------------------------------*\
70+ | If status is in the 200 range the request was successful |
71+ \*-------------------------------------------------------------*/
7272 if ((status / 100 ) == 2 )
7373 {
7474 if (response_data)
0 commit comments