10
10
#include " LogManager.h"
11
11
#include " httplib.h"
12
12
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
-
20
13
long APIRequest (std::string method, std::string location, std::string URI, json* request_data = nullptr , json* response_data = nullptr )
21
14
{
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);
23
19
24
20
/* -------------------------------------------------------------*\
25
21
| Create httplib Client and variables to hold result |
@@ -28,6 +24,9 @@ long APIRequest(std::string method, std::string location, std::string URI, json*
28
24
int status = 0 ;
29
25
std::string body = " " ;
30
26
27
+ /* -------------------------------------------------------------*\
28
+ | Perform the appropriate call for the given method |
29
+ \*-------------------------------------------------------------*/
31
30
if (method == " GET" )
32
31
{
33
32
httplib::Result result = client.Get (URI.c_str ());
@@ -67,8 +66,9 @@ long APIRequest(std::string method, std::string location, std::string URI, json*
67
66
body = result->body ;
68
67
}
69
68
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
+ \*-------------------------------------------------------------*/
72
72
if ((status / 100 ) == 2 )
73
73
{
74
74
if (response_data)
0 commit comments