Пример #1
0
 /**
  * Lancement de l'application
  *
  * @return Route
  */
 public function run()
 {
     /**
      * Home
      */
     $this->router->get('/', function () {
         Response::json("Bienvenue sur l'API Deezer", 200);
     })->get('user', 'UserController@index')->get('user/:id', 'UserController@show')->get('user/:id/favorites', 'UserController@showFavorites')->post('user', 'UserController@store')->post('user/:id/favorites', 'UserController@storeFavorite')->delete('user/:id/favorites/:song_id', 'UserController@destroyFavorite')->get('song', 'SongController@index')->get('song/:id', 'SongController@show')->post('song', 'SongController@store')->run();
 }
Пример #2
0
 /**
  * Déroulement de la liste des routes enregistrées pour matching
  *
  * @return Route
  */
 public function run()
 {
     if (!isset($this->routes[Request::getRequestMethod()])) {
         Response::json404();
     }
     foreach ($this->routes[Request::getRequestMethod()] as $route) {
         if ($route->match(Request::getCurrentUri())) {
             return $route->call();
         }
     }
     Response::json404();
 }