public function get($url) { $cached = $this->cache_get($url); if (isset($cached)) { return $cached; } $content = parent::get($url); $this->cache_put($url, $content); return $content; }
exit; } if (!in_array($path[0], array_keys($config["services"]))) { header("HTTP/1.1 404 Not Found"); exit; } if ($_SERVER["REQUEST_METHOD"] == "GET") { $reqpath = array_slice($path, 1); $uri = $config["services"][$path[0]]["connector_url"] . join($reqpath, "/"); if (preg_match("/\\/\$/", $url["path"])) { $uri .= "/"; } if (count($_GET) > 0) { $uri .= "?" . http_build_query($_GET); } $http = new HttpGet($uri, $config["server"]["base_url"] . $path[0]); if ($_SERVER['PHP_AUTH_USER'] && $_SERVER['PHP_AUTH_PW']) { $http->setBasicAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } $http->doGet(); $statusMap = array(400 => array("message" => "Bad Request", "body" => "An illegal request was sent, most likely an invalid query parameter"), 401 => array("message" => "Unauthorized", "body" => "Authorization required to view this resource"), 403 => array("message" => "Forbidden", "body" => "You have not been authorized to view this resource"), 404 => array("message" => "Not Found", "body" => "The requested resource does not exist"), 405 => array("message" => "Method Not Allowed", "body" => "This resource does not permit GET requests"), 410 => array("message" => "Gone", "body" => "This resource no longer exists")); if ($http->getStatus() != 200 && $http->getStatus() != 304) { header("HTTP/1.1 " . $http->getStatus() . " " . $statusMap[$http->getStatus()]["message"]); if ($auth = $http->getAuthHeaders()) { header("WWW-Authenticate: " . $auth); } echo $statusMap[$http->getStatus()]["body"]; exit; } $json = json_decode($http->getBody()); switch ($json->type) {