1 <?php |
1 <?php |
2 |
2 |
3 namespace CorpusParole\Providers; |
3 namespace CorpusParole\Providers; |
4 |
4 |
5 use Illuminate\Routing\Router; |
5 use Illuminate\Support\Facades\Route; |
6 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
6 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
7 |
7 |
8 class RouteServiceProvider extends ServiceProvider |
8 class RouteServiceProvider extends ServiceProvider |
9 { |
9 { |
10 /** |
10 /** |
11 * This namespace is applied to the controller routes in your routes file. |
11 * This namespace is applied to your controller routes. |
12 * |
12 * |
13 * In addition, it is set as the URL generator's root namespace. |
13 * In addition, it is set as the URL generator's root namespace. |
14 * |
14 * |
15 * @var string |
15 * @var string |
16 */ |
16 */ |
17 protected $namespace = 'CorpusParole\Http\Controllers'; |
17 protected $namespace = 'CorpusParole\Http\Controllers'; |
18 |
18 |
19 /** |
19 /** |
20 * Define your route model bindings, pattern filters, etc. |
20 * Define your route model bindings, pattern filters, etc. |
21 * |
21 * |
22 * @param \Illuminate\Routing\Router $router |
22 * @return void |
23 */ |
23 */ |
24 public function boot(Router $router) |
24 public function boot() |
25 { |
25 { |
26 parent::boot($router); |
26 // |
|
27 |
|
28 parent::boot(); |
|
29 } |
|
30 |
|
31 /** |
|
32 * Define the routes for the application. |
|
33 * |
|
34 * @return void |
|
35 */ |
|
36 public function map() |
|
37 { |
|
38 $this->mapApiRoutes(); |
|
39 |
|
40 $this->mapWebRoutes(); |
|
41 |
|
42 $this->mapProxyRoutes(); |
27 |
43 |
28 // |
44 // |
29 } |
45 } |
30 |
46 |
31 /** |
47 /** |
32 * Define the routes for the application. |
48 * Define the "web" routes for the application. |
33 * |
49 * |
34 * @param \Illuminate\Routing\Router $router |
50 * These routes all receive session state, CSRF protection, etc. |
|
51 * |
|
52 * @return void |
35 */ |
53 */ |
36 public function map(Router $router) |
54 protected function mapWebRoutes() |
37 { |
55 { |
38 $router->group(['namespace' => $this->namespace], function ($router) { |
56 Route::group([ |
39 require app_path('Http/routes.php'); |
57 'middleware' => 'web', |
|
58 'namespace' => $this->namespace, |
|
59 ], function ($router) { |
|
60 require base_path('routes/web.php'); |
40 }); |
61 }); |
41 } |
62 } |
|
63 |
|
64 /** |
|
65 * Define the "api" routes for the application. |
|
66 * |
|
67 * These routes are typically stateless. |
|
68 * |
|
69 * @return void |
|
70 */ |
|
71 protected function mapApiRoutes() |
|
72 { |
|
73 Route::group([ |
|
74 'middleware' => 'cors', |
|
75 'namespace' => $this->namespace, |
|
76 'prefix' => 'api', |
|
77 ], function ($router) { |
|
78 require base_path('routes/api.php'); |
|
79 }); |
|
80 } |
|
81 |
|
82 /** |
|
83 * Define the "api" routes for the application. |
|
84 * |
|
85 * These routes are typically stateless. |
|
86 * |
|
87 * @return void |
|
88 */ |
|
89 protected function mapProxyRoutes() |
|
90 { |
|
91 Route::group([ |
|
92 'middleware' => 'cors', |
|
93 'namespace' => $this->namespace, |
|
94 'prefix' => 'proxy', |
|
95 ], function ($router) { |
|
96 require base_path('routes/api.php'); |
|
97 }); |
|
98 } |
|
99 |
42 } |
100 } |