mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Directly return without buffering in the API handler.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+26
-31
@@ -18,113 +18,108 @@
|
||||
int api_handler(struct mg_connection *conn, void *ignored)
|
||||
{
|
||||
const struct mg_request_info *request = mg_get_request_info(conn);
|
||||
// HTTP response
|
||||
int ret = 0;
|
||||
/******************************** api/dns ********************************/
|
||||
if(startsWith("/api/dns/status", request->local_uri))
|
||||
{
|
||||
ret = api_dns_status(conn);
|
||||
return api_dns_status(conn);
|
||||
}
|
||||
else if(startsWith("/api/dns/whitelist/exact", request->local_uri))
|
||||
{
|
||||
ret = api_dns_somelist(conn, true, true);
|
||||
return api_dns_somelist(conn, true, true);
|
||||
}
|
||||
else if(startsWith("/api/dns/whitelist/regex", request->local_uri))
|
||||
{
|
||||
ret = api_dns_somelist(conn, false, true);
|
||||
return api_dns_somelist(conn, false, true);
|
||||
}
|
||||
else if(startsWith("/api/dns/blacklist/exact", request->local_uri))
|
||||
{
|
||||
ret = api_dns_somelist(conn, true, false);
|
||||
return api_dns_somelist(conn, true, false);
|
||||
}
|
||||
else if(startsWith("/api/dns/blacklist/regex", request->local_uri))
|
||||
{
|
||||
ret = api_dns_somelist(conn, false, false);
|
||||
return api_dns_somelist(conn, false, false);
|
||||
}
|
||||
/******************************** api/ftl ****************************/
|
||||
else if(startsWith("/api/ftl/clientIP", request->local_uri))
|
||||
{
|
||||
ret = api_ftl_clientIP(conn);
|
||||
return api_ftl_clientIP(conn);
|
||||
}
|
||||
/******************************** api/stats **************************/
|
||||
else if(startsWith("/api/stats/summary", request->local_uri))
|
||||
{
|
||||
ret = api_stats_summary(conn);
|
||||
return api_stats_summary(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/overTime/history", request->local_uri))
|
||||
{
|
||||
ret = api_stats_overTime_history(conn);
|
||||
return api_stats_overTime_history(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/overTime/clients", request->local_uri))
|
||||
{
|
||||
ret = api_stats_overTime_clients(conn);
|
||||
return api_stats_overTime_clients(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/query_types", request->local_uri))
|
||||
{
|
||||
ret = api_stats_query_types(conn);
|
||||
return api_stats_query_types(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/upstreams", request->local_uri))
|
||||
{
|
||||
ret = api_stats_upstreams(conn);
|
||||
return api_stats_upstreams(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/top_domains", request->local_uri))
|
||||
{
|
||||
ret = api_stats_top_domains(false, conn);
|
||||
return api_stats_top_domains(false, conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/top_blocked", request->local_uri))
|
||||
{
|
||||
ret = api_stats_top_domains(true, conn);
|
||||
return api_stats_top_domains(true, conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/top_clients", request->local_uri))
|
||||
{
|
||||
ret = api_stats_top_clients(false, conn);
|
||||
return api_stats_top_clients(false, conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/top_blocked_clients", request->local_uri))
|
||||
{
|
||||
ret = api_stats_top_clients(true, conn);
|
||||
return api_stats_top_clients(true, conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/history", request->local_uri))
|
||||
{
|
||||
ret = api_stats_history(conn);
|
||||
return api_stats_history(conn);
|
||||
}
|
||||
else if(startsWith("/api/stats/recent_blocked", request->local_uri))
|
||||
{
|
||||
ret = api_stats_recentblocked(conn);
|
||||
return api_stats_recentblocked(conn);
|
||||
}
|
||||
/******************************** api/version ****************************/
|
||||
else if(startsWith("/api/version", request->local_uri))
|
||||
{
|
||||
ret = api_version(conn);
|
||||
return api_version(conn);
|
||||
}
|
||||
/******************************** api/auth ****************************/
|
||||
else if(startsWith("/api/auth", request->local_uri))
|
||||
{
|
||||
ret = api_auth(conn);
|
||||
return api_auth(conn);
|
||||
}
|
||||
else if(startsWith("/api/auth/salt", request->local_uri))
|
||||
{
|
||||
ret = api_auth_salt(conn);
|
||||
return api_auth_salt(conn);
|
||||
}
|
||||
/******************************** api/settings ****************************/
|
||||
else if(startsWith("/api/settings/web", request->local_uri))
|
||||
{
|
||||
ret = api_settings_web(conn);
|
||||
return api_settings_web(conn);
|
||||
}
|
||||
else if(startsWith("/api/settings/ftldb", request->local_uri))
|
||||
{
|
||||
ret = api_settings_ftldb(conn);
|
||||
return api_settings_ftldb(conn);
|
||||
}
|
||||
/******************************** not found ******************************/
|
||||
else
|
||||
{
|
||||
cJSON *json = JSON_NEW_OBJ();
|
||||
JSON_OBJ_REF_STR(json, "path", request->local_uri);
|
||||
|
||||
ret = send_json_error(conn, 404,
|
||||
"not_found",
|
||||
"Not found",
|
||||
json, NULL);
|
||||
return send_json_error(conn, 404,
|
||||
"not_found",
|
||||
"Not found",
|
||||
json, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user