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 * Define your route model bindings, pattern filters, etc.
27 public function boot()
29 $this->configureRateLimiting();
31 $this->routes(function () {
32 $this->mapWebRoutes();
33 $this->mapApiRoutes();
38 * Define the "web" routes for the application.
40 * These routes all receive session state, CSRF protection, etc.
44 protected function mapWebRoutes()
47 'middleware' => 'web',
48 'namespace' => $this->namespace,
49 ], function ($router) {
50 require base_path('routes/web.php');
55 * Define the "api" routes for the application.
57 * These routes are typically stateless.
61 protected function mapApiRoutes()
64 'middleware' => 'api',
65 'namespace' => $this->namespace . '\Api',
67 ], function ($router) {
68 require base_path('routes/api.php');
73 * Configure the rate limiters for the application.
77 protected function configureRateLimiting()
79 RateLimiter::for('api', function (Request $request) {
80 return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());