resp->body = makeStringFromDocument(doc);
}
+static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
+ string zonename = req->path_parameters["id"];
+
+ if(req->method != "GET")
+ throw HttpMethodNotAllowedException();
+
+ resp->body = getZone(zonename);
+}
+
void StatWebServer::jsonstat(HttpRequest* req, HttpResponse* resp)
{
string command;
registerApiHandler("/servers/localhost/config", &apiServerConfig);
registerApiHandler("/servers/localhost/search-log", &apiServerSearchLog);
registerApiHandler("/servers/localhost/zones", &apiServerZones);
+ registerApiHandler("/servers/localhost/zones/<id>", &apiServerZoneDetail);
// legacy dispatch
registerApiHandler("/jsonstat", boost::bind(&StatWebServer::jsonstat, this, _1, _2));
}
self.assertIn(k, data)
if k in payload:
self.assertEquals(data[k], payload[k])
+
+ def test_GetZone(self):
+ r = self.session.get(self.url("/servers/localhost/zones"))
+ domains = r.json()
+ example_com = [domain for domain in domains if domain['name'] == u'example.com'][0]
+ r = self.session.get(self.url("/servers/localhost/zones/" + example_com['id']))
+ self.assertSuccessJson(r)
+ data = r.json()
+ for k in ('id', 'url', 'name', 'masters', 'kind', 'last_check', 'notified_serial', 'serial'):
+ self.assertIn(k, data)
+ self.assertEquals(data['name'], 'example.com')