// route() makes no assumptions about the contents of variables except
// that the following URL segment can't be part of the variable.
//
+// Note: ORDER of registration MATTERS:
+// URLs that do a more specific match should come FIRST.
+//
// Examples:
-// registerHandler("/", &index);
-// registerHandler("/foo", &foo);
// registerHandler("/foo/<bar>/<baz>", &foobarbaz);
+// registerHandler("/foo/<bar>", &foobar);
+// registerHandler("/foo", &foo);
+// registerHandler("/", &index);
void WebServer::registerHandler(const string& url, HandlerFunction handler)
{
std::size_t pos = 0, lastpos = 0;
void StatWebServer::launch()
{
try {
- d_ws->registerHandler("/", boost::bind(&StatWebServer::indexfunction, this, _1, _2));
- d_ws->registerHandler("/style.css", boost::bind(&StatWebServer::cssfunction, this, _1, _2));
if(::arg().mustDo("experimental-json-interface")) {
- registerApiHandler("/servers", &apiServer);
- registerApiHandler("/servers/localhost", &apiServerDetail);
registerApiHandler("/servers/localhost/config", &apiServerConfig);
registerApiHandler("/servers/localhost/search-log", &apiServerSearchLog);
- registerApiHandler("/servers/localhost/zones", &apiServerZones);
registerApiHandler("/servers/localhost/zones/<id>", &apiServerZoneDetail);
+ registerApiHandler("/servers/localhost/zones", &apiServerZones);
+ registerApiHandler("/servers/localhost", &apiServerDetail);
+ registerApiHandler("/servers", &apiServer);
// legacy dispatch
registerApiHandler("/jsonstat", boost::bind(&StatWebServer::jsonstat, this, _1, _2));
}
+ d_ws->registerHandler("/style.css", boost::bind(&StatWebServer::cssfunction, this, _1, _2));
+ d_ws->registerHandler("/", boost::bind(&StatWebServer::indexfunction, this, _1, _2));
d_ws->go();
}
catch(...) {