Skip to content

Commit

Permalink
mount middlewares and routes on different methods. #78
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jul 30, 2014
1 parent ca175ba commit b3e885d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

require __DIR__ . '/vendor/autoload.php';
$app = require __DIR__ . '/src/Hook.php';
Hook\Http\Router::mount($app);
$app->run();
Hook\Http\Router::setup($app)->run();
13 changes: 11 additions & 2 deletions src/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class Router {
protected static $instance;

public static function mount($app)
public static function setup($app)
{
static::$instance = $app;
static::setInstance($app);

//
// Setup middlewares
Expand All @@ -19,6 +19,11 @@ public static function mount($app)
$app->add(new Middlewares\AuthMiddleware());
$app->add(new Middlewares\AppMiddleware());

return static::mount($app);
}

public static function mount($app)
{
// System
$app->get('/system/time', 'Hook\\Controllers\\SystemController:time');
$app->get('/system/ip', 'Hook\\Controllers\\SystemController:ip');
Expand Down Expand Up @@ -72,6 +77,10 @@ public static function mount($app)
return $app;
}

public static function setInstance($instance) {
static::$instance = $instance;
}

public static function getInstance() {
return static::$instance;
}
Expand Down

0 comments on commit b3e885d

Please sign in to comment.