/** * @param \string $method http method * @param \string $uri Resource URI * @param \string $class class and or function qualifying string * @param \array $options supported extension for this resource. used to override server defaults * \array $pre_modules modules to be executed before the mapped action * \array $post_modules modules to be executed after the mapped action */ public function __construct($method, $uri, $class, $options) { parent::__construct(); $this->method = $method; $this->uri = $uri; $this->class = $class; $this->addExtensions($options['extensions']); $this->addPreModules($options['pre_modules']); // $this->addPostModules($options['pre_modules']); // $this->post_modules = $post_modules; }
/** * Constructor * @param string $query Optional query to be treat as the URL * @return \Rest\Server $rest; */ public function __construct($query = null) { parent::__construct(); // Request handler $this->request = new Request($this); // Response holder $this->response = new Response($this); // extensions the server handles $this->extensions = array(); // modules to be executed before mapping $this->pre_map_modules = array(); // set the base url if (isset($_SERVER["HTTP_HOST"])) { $this->baseUrl = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]); } // If will use custom URI or HTTP requested URI if ($query === null) { $this->query = $this->getRequest()->getRequestURI(); } else { $this->query = $query; } $this->getRequest()->setURI($this->query); $this->matched = false; }