} } } public static $named_codes = array("forbidden" => 403, "not-found" => 404, "bad-method" => 405, "failure" => 406, "success" => 200, "created" => 201, "empty" => 204); public static function response_code($id = false, $doSend = true) { if (!$id) { return http_response_code(); } $i = strtolower($id); if (array_key_exists($i, REST::$named_codes)) { $code = REST::$named_codes[$i]; } else { $code = $id; } if ($doSend) { http_response_code($code); } return $code; } } if (isset($_REQUEST['_url'])) { $uri = $_REQUEST['_url']; if (strpos($uri, "/") === 0) { $uri = substr($uri, 1); } $uri = trim($uri, "/"); REST::$URI = $uri; REST::$ARGS = explode("/", $uri); REST::$REQUEST_METHOD = strtoupper($_SERVER["REQUEST_METHOD"]); }