mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
b144191eff
commit
1b8fd9637f
@ -22,16 +22,25 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_URLHANDLER("/v1", InfoHandler);
|
REGISTER_URLHANDLER("/", InfoHandler);
|
||||||
|
|
||||||
bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
|
bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
|
||||||
{
|
{
|
||||||
if (request.RequestUrl->GetPath().size() != 1)
|
if (request.RequestUrl->GetPath().size() > 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (request.RequestMethod != "GET")
|
if (request.RequestMethod != "GET")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (request.RequestUrl->GetPath().empty()) {
|
||||||
|
response.SetStatus(302, "Found");
|
||||||
|
response.AddHeader("Location", "/v1");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.RequestUrl->GetPath()[0] != "v1")
|
||||||
|
return false;
|
||||||
|
|
||||||
response.SetStatus(200, "OK");
|
response.SetStatus(200, "OK");
|
||||||
response.AddHeader("Content-Type", "text/html");
|
response.AddHeader("Content-Type", "text/html");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user