RouteServiceProvider.php 2.1 KB

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