/** * This method takes the given request finds the resource and gets the response from the * resources controller. * * @param Request $r * @return string */ public static function dispatch(Request $r) { $res = self::getListener($r->getKey()); if ($res != NULL) { return $res->getController($r)->getResponse(); } // if we rebuild on 404, disable this for performance if (Registry::get("AUTO_REBUILD_REQUEST_MAP")) { RequestMapGenerator::buildAll(true); $res = self::getListener($r->getKey()); if ($res != NULL) { return $res->getController($r)->getResponse(); } } // otherwise 404 (no need to add die, execution will end anyway header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); }