/** * Boot the service provider. * * @return void */ public function boot() { parent::boot(); $this->publishes([realpath(__DIR__ . '/../../config/api.php') => config_path('api.php')]); $kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel'); $this->app['Dingo\\Api\\Http\\Middleware\\Request']->mergeMiddlewares($this->gatherAppMiddleware($kernel)); $this->addRequestMiddlewareToBeginning($kernel); $this->app['events']->listen(RequestWasMatched::class, function (RequestWasMatched $event) { $this->replaceRouteDispatcher(); $this->updateRouterBindings(); }); }
/** * Boot the service provider. * * @return void */ public function boot() { parent::boot(); $this->publishes([realpath(__DIR__ . '/../../config/api.php') => config_path('api.php')]); $kernel = $this->app->make(Kernel::class); $this->app[Request::class]->mergeMiddlewares($this->gatherAppMiddleware($kernel)); $this->addRequestMiddlewareToBeginning($kernel); $this->app['events']->listen(RequestWasMatched::class, function (RequestWasMatched $event) { $this->replaceRouteDispatcher(); $this->updateRouterBindings(); }); $this->app['router']->middleware('api.auth', Auth::class); $this->app['router']->middleware('api.throttle', RateLimit::class); $this->app['router']->middleware('api.controllers', PrepareController::class); }
/** * Boot the service provider. * * @return void */ public function boot() { parent::boot(); // Because Lumen sets the route resolver at a very weird point we're going to // have to use reflection whenever the request instance is rebound to // set the route resolver to get the current route. $this->app->rebinding('Illuminate\\Http\\Request', function ($app, $request) { $request->setRouteResolver(function () use($app) { $reflection = new ReflectionClass($app); $property = $reflection->getProperty('currentRoute'); $property->setAccessible(true); return $property->getValue($app); }); }); $this->app->routeMiddleware(['api.auth' => 'Dingo\\Api\\Http\\Middleware\\Auth', 'api.throttle' => 'Dingo\\Api\\Http\\Middleware\\RateLimit', 'api.controllers' => 'Dingo\\Api\\Http\\Middleware\\PrepareController']); }
/** * Boot the service provider. * * @return void */ public function boot() { parent::boot(); $this->app->configure('api'); $reflection = new ReflectionClass($this->app); $this->app[Request::class]->mergeMiddlewares($this->gatherAppMiddleware($reflection)); $this->addRequestMiddlewareToBeginning($reflection); // Because Lumen sets the route resolver at a very weird point we're going to // have to use reflection whenever the request instance is rebound to // set the route resolver to get the current route. $this->app->rebinding(IlluminateRequest::class, function ($app, $request) { $request->setRouteResolver(function () use($app) { $reflection = new ReflectionClass($app); $property = $reflection->getProperty('currentRoute'); $property->setAccessible(true); return $property->getValue($app); }); }); $this->app->routeMiddleware(['api.auth' => Auth::class, 'api.throttle' => RateLimit::class, 'api.controllers' => PrepareController::class]); }