3 namespace BookStack\Providers;
5 use Illuminate\Cache\RateLimiting\Limit;
6 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7 use Illuminate\Http\Request;
8 use Illuminate\Support\Facades\RateLimiter;
9 use Illuminate\Support\Facades\Route;
11 class RouteServiceProvider extends ServiceProvider
14 * The path to the "home" route for your application.
16 * This is used by Laravel authentication to redirect users after login.
20 public const HOME = '/';
23 * This namespace is applied to the controller routes in your routes file.
25 * In addition, it is set as the URL generator's root namespace.
31 * Define your route model bindings, pattern filters, etc.
35 public function boot()
37 $this->configureRateLimiting();
39 $this->routes(function () {
40 $this->mapWebRoutes();
41 $this->mapApiRoutes();
46 * Define the "web" routes for the application.
48 * These routes all receive session state, CSRF protection, etc.
52 protected function mapWebRoutes()
55 'middleware' => 'web',
56 'namespace' => $this->namespace,
57 ], function ($router) {
58 require base_path('routes/web.php');
63 * Define the "api" routes for the application.
65 * These routes are typically stateless.
69 protected function mapApiRoutes()
72 'middleware' => 'api',
73 'namespace' => $this->namespace . '\Api',
75 ], function ($router) {
76 require base_path('routes/api.php');
81 * Configure the rate limiters for the application.
85 protected function configureRateLimiting()
87 RateLimiter::for('api', function (Request $request) {
88 return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());