]> granicus.if.org Git - icinga2/commitdiff
Fix incorrect URL for status queries
authorGunnar Beutner <gunnar@beutner.name>
Tue, 28 Jul 2015 12:54:16 +0000 (14:54 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 28 Jul 2015 12:54:16 +0000 (14:54 +0200)
refs #9077

lib/remote/statusqueryhandler.cpp

index ea6c54649b9113cf455bd475cff3ce6d9d484a43..0651b93aa52d4e8370763dfce8c31d2061a1b10d 100644 (file)
 
 using namespace icinga;
 
-REGISTER_URLHANDLER("/", StatusQueryHandler);
+REGISTER_URLHANDLER("/v1", StatusQueryHandler);
 
 bool StatusQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
 {
-       if (request.RequestUrl->GetPath().empty())
+       if (request.RequestUrl->GetPath().size() < 2)
                return false;
 
-       Type::Ptr type = FilterUtility::TypeFromPluralName(request.RequestUrl->GetPath()[0]);
+       Type::Ptr type = FilterUtility::TypeFromPluralName(request.RequestUrl->GetPath()[1]);
 
        if (!type)
                return false;
@@ -44,10 +44,10 @@ bool StatusQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
 
        params->Set("type", type->GetName());
 
-       if (request.RequestUrl->GetPath().size() > 1) {
+       if (request.RequestUrl->GetPath().size() >= 3) {
                String attr = type->GetName();
                boost::algorithm::to_lower(attr);
-               params->Set(attr, request.RequestUrl->GetPath()[1]);
+               params->Set(attr, request.RequestUrl->GetPath()[2]);
        } else if (!params->Contains("filter")) {
                params->Set("filter", "true");
        }