/** * Prepare Rest request * * @access protected */ protected function prepare_rest() { if (Request::main() !== Request::active()) { $this->set_content_type = false; } $this->template = null; Restserver::auth(); }
/** * Takes pure data and optionally a status code, then creates the response * * @access protected * @param array $data * @param int $http_code */ protected function response($data = array(), $http_code = 200) { if (is_array($data) and empty($data) or $data == '') { $this->response->status = $this->no_data_status; return; } $rest_server = Restserver::make($data, $http_code)->format($this->rest_format)->execute(); $this->response->body = $rest_server->body; $this->response->status = $rest_server->status; if (true === $this->set_content_type) { // Set the correct format header $this->response->set_header('Content-Type', Restserver::content_type($rest_server->format)); } }