aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_httpd_stats.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-05-21 16:32:13 +0100
committerGravatar Sadie Powell2022-06-07 20:26:38 +0100
commite713bd4986d557d7e0f178dcb5ff3a0e6d858890 (patch)
treeba6af2787276d40f0ede2247767d29160502eeef /src/modules/m_httpd_stats.cpp
parentRelease v4.0.0 alpha 11. (diff)
Get rid of an indirection when handling the httpd_stats request.
Diffstat (limited to 'src/modules/m_httpd_stats.cpp')
-rw-r--r--src/modules/m_httpd_stats.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 70f4397b3..c96566f8d 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -464,17 +464,16 @@ public:
enableparams = conf->getBool("enableparams");
}
- ModResult HandleRequest(HTTPRequest* http)
+ ModResult OnHTTPRequest(HTTPRequest& request) override
{
- if (http->GetPath().compare(0, 6, "/stats"))
+ if (request.GetPath().compare(0, 6, "/stats"))
return MOD_RES_PASSTHRU;
- ServerInstance->Logs.Debug(MODNAME, "Handling HTTP request for %s", http->GetPath().c_str());
-
+ ServerInstance->Logs.Debug(MODNAME, "Handling HTTP request for %s", request.GetPath().c_str());
Stats::XMLSerializer serializer;
serializer.BeginBlock("inspircdstats");
- if (http->GetPath() == "/stats")
+ if (request.GetPath() == "/stats")
{
Stats::ServerInfo(serializer);
Stats::General(serializer);
@@ -485,14 +484,14 @@ public:
Stats::Servers(serializer);
Stats::Commands(serializer);
}
- else if (http->GetPath() == "/stats/general")
+ else if (request.GetPath() == "/stats/general")
{
Stats::General(serializer);
}
- else if (http->GetPath() == "/stats/users")
+ else if (request.GetPath() == "/stats/users")
{
if (enableparams)
- Stats::ListUsers(serializer, http->GetParsedURI().query_params);
+ Stats::ListUsers(serializer, request.GetParsedURI().query_params);
else
Stats::Users(serializer);
}
@@ -503,17 +502,12 @@ public:
serializer.EndBlock();
/* Send the document back to m_httpd */
- HTTPDocumentResponse response(this, *http, serializer.GetData(), 200);
+ HTTPDocumentResponse response(this, request, serializer.GetData(), 200);
response.headers.SetHeader("X-Powered-By", MODNAME);
response.headers.SetHeader("Content-Type", "text/xml");
API->SendResponse(response);
return MOD_RES_DENY; // Handled
}
-
- ModResult OnHTTPRequest(HTTPRequest& req) override
- {
- return HandleRequest(&req);
- }
};
MODULE_INIT(ModuleHttpStats)