diff -r 5d2621f71f39 -r 59a2c10ac9b8 server/src/app/Providers/RouteServiceProvider.php --- a/server/src/app/Providers/RouteServiceProvider.php Thu Sep 22 15:42:12 2016 +0200 +++ b/server/src/app/Providers/RouteServiceProvider.php Thu Sep 22 16:05:08 2016 +0200 @@ -2,13 +2,13 @@ namespace CorpusParole\Providers; -use Illuminate\Routing\Router; +use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider { /** - * This namespace is applied to the controller routes in your routes file. + * This namespace is applied to your controller routes. * * In addition, it is set as the URL generator's root namespace. * @@ -19,24 +19,82 @@ /** * Define your route model bindings, pattern filters, etc. * - * @param \Illuminate\Routing\Router $router + * @return void */ - public function boot(Router $router) + public function boot() { - parent::boot($router); + // + + parent::boot(); + } + + /** + * Define the routes for the application. + * + * @return void + */ + public function map() + { + $this->mapApiRoutes(); + + $this->mapWebRoutes(); + + $this->mapProxyRoutes(); // } /** - * Define the routes for the application. + * Define the "web" routes for the application. * - * @param \Illuminate\Routing\Router $router + * These routes all receive session state, CSRF protection, etc. + * + * @return void */ - public function map(Router $router) + protected function mapWebRoutes() { - $router->group(['namespace' => $this->namespace], function ($router) { - require app_path('Http/routes.php'); + Route::group([ + 'middleware' => 'web', + 'namespace' => $this->namespace, + ], function ($router) { + require base_path('routes/web.php'); }); } -} + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::group([ + 'middleware' => 'cors', + 'namespace' => $this->namespace, + 'prefix' => 'api', + ], function ($router) { + require base_path('routes/api.php'); + }); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapProxyRoutes() + { + Route::group([ + 'middleware' => 'cors', + 'namespace' => $this->namespace, + 'prefix' => 'proxy', + ], function ($router) { + require base_path('routes/api.php'); + }); + } + +} \ No newline at end of file