Initial JSON API implementation

This commit is contained in:
fireice-uk
2017-07-12 23:07:08 +01:00
parent 74c691470c
commit 9f0a90e7db
6 changed files with 171 additions and 5 deletions
+7
View File
@@ -84,6 +84,13 @@ int httpd::req_handler(void * cls,
MHD_add_response_header(rsp, "ETag", sHtmlCssEtag);
MHD_add_response_header(rsp, "Content-Type", "text/css; charset=utf-8");
}
else if(strcasecmp(url, "/api.json") == 0)
{
executor::inst()->get_http_report(EV_HTML_JSON, str);
rsp = MHD_create_response_from_buffer(str.size(), (void*)str.c_str(), MHD_RESPMEM_MUST_COPY);
MHD_add_response_header(rsp, "Content-Type", "application/json; charset=utf-8");
}
else if(strcasecmp(url, "/h") == 0 || strcasecmp(url, "/hashrate") == 0)
{
executor::inst()->get_http_report(EV_HTML_HASHRATE, str);