Compare commits

...

2 Commits

Author SHA1 Message Date
sheychen 3c42b524d7 Fix redirect 2018-05-13 13:37:01 +02:00
sheychen 9b5983a35f Typing and 404 2017-09-10 20:14:22 +02:00
2 changed files with 6 additions and 6 deletions

View File

@ -59,11 +59,11 @@ class App{
$this->router = new Router(isset($data['router']) ? $data['router'] : Path::get('config').'/Routes.php');
}
public function run($uri = null, array $filters = array()){
public function run(string $uri = null, array $filters = array()){
$route = $this->router->run(($uri ?: $_SERVER['REQUEST_URI']), $filters);
if(!isset($route))
$this->error(new HttpException(404, 'Not Found'));
$this->error(new HttpException(404));
try{
$route->call($this, $this->config['namespace'], $this->config['controller']);

View File

@ -31,7 +31,7 @@ class Router{
* @param callable|string $callable Function to run or 'Controller#function'
* @return Route
*/
public function add(string $path, $callable):Route{
public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
@ -44,7 +44,7 @@ class Router{
* @param array $filters
* @return Route|null
*/
public function run(string $url, array $filters):?Route{
public function run(string $url, array $filters){
foreach($this->routes as $route){
if($route->match($url, $filters))
return $route;
@ -58,7 +58,7 @@ class Router{
* @param string $name
* @return Route|null
*/
public function get(string $name):?Route{
public function get(string $name){
foreach($this->routes as $route){
if($route->matchName($name))
return $route;
@ -74,7 +74,7 @@ class Router{
* @return void
*/
public static function redirect(string $url, bool $stop = true){
header('Location: '.$url);
header('Location: /'.$url);
if($stop)
exit();
}