Пример #1
0
 /**
  * Boot the service provider.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @return void
  */
 public function boot()
 {
     // Set response static instances
     $this->setResponseStaticInstances();
     // Configure the "Accept"-header parser
     DingoHttpRequest::setAcceptParser($this->app['Dingo\\Api\\Http\\Parser\\Accept']);
     // Rebind API router
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
     // Initiate HTTP kernel
     $kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel');
     /// Add middlewares to HTTP request
     $this->app[NodesHttpMiddlewareRequest::class]->mergeMiddlewares($this->gatherAppMiddleware($kernel));
     // Prepend request middleware
     $this->addRequestMiddlewareToBeginning($kernel);
     // Replace route dispatcher
     $this->app['events']->listen(DingoEventRequestWasMatched::class, function (DingoEventRequestWasMatched $event) {
         $this->replaceRouteDispatcher();
         $this->updateRouterBindings();
     });
     // Load project routes
     $this->loadRoutes();
     // Register namespace for API views
     $this->loadViewsFrom(__DIR__ . '/../resources/views', 'nodes.api');
     // Register publish groups
     $this->publishGroups();
 }
Пример #2
0
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setResponseStaticInstances();
     Request::setAcceptParser($this->app['Dingo\\Api\\Http\\Parser\\Accept']);
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
 }
 /**
  * Boot the service provider.
  *
  * @return void
  */
 public function boot()
 {
     $this->setupConfig();
     Http\Response::setFormatters($this->prepareConfigValues($this->app['config']['api.formats']));
     Http\Response::setTransformer($this->app['api.transformer']);
     Http\Response::setEventDispatcher($this->app['events']);
     $config = $this->app['config']['api'];
     Http\Request::setAcceptParser(new Http\Parser\Accept($config['standardsTree'], $config['subtype'], $config['version'], $config['defaultFormat']));
     $this->app->rebinding('api.routes', function ($app, $routes) {
         $app['api.url']->setRouteCollections($routes);
     });
 }