/** * Do the routing and call the closure * * @return \Wrr\Response\AbstractResponse */ public function route() { if (is_callable($this->function)) { $fun = $this->function; $this->response->addBodyFragment($fun()); } return $this->response; }
/** * Do the routing and call the closure * * @return AbstractResponse * @throws \Exception */ public function route() { if (is_callable($this->function)) { $fun = $this->function; $result = $fun(); if (is_scalar($result)) { $this->response->addBodyFragment($result); } elseif (method_exists($this->response, 'setData')) { $this->response->setData($result); } else { throw new \Exception('No Result to Route', 500); } } return $this->response; }
/** * @return AbstractResponse */ public function route() { $this->response->addBodyFragment("You are in Admin Land... be careful."); return $this->response; }