コード例 #1
0
ファイル: Request.php プロジェクト: JamesGuthrie/api
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     try {
         if ($this->validator->validateRequest($request)) {
             $this->app->singleton('Illuminate\\Contracts\\Debug\\ExceptionHandler', function ($app) {
                 return $app['Dingo\\Api\\Contract\\Debug\\ExceptionHandler'];
             });
             $request = $this->app->make('Dingo\\Api\\Contract\\Http\\Request')->createFromIlluminate($request);
             $this->events->fire(new RequestWasMatched($request, $this->app));
             return $this->sendRequestThroughRouter($request);
         }
     } catch (Exception $exception) {
         $this->exception->report($exception);
         return $this->exception->handle($exception);
     }
     return $next($request);
 }
コード例 #2
0
ファイル: Request.php プロジェクト: dingo/api
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     try {
         if ($this->validator->validateRequest($request)) {
             $this->app->singleton(LaravelExceptionHandler::class, function ($app) {
                 return $app[ExceptionHandler::class];
             });
             $request = $this->app->make(RequestContract::class)->createFromIlluminate($request);
             $this->events->fire(new RequestWasMatched($request, $this->app));
             return $this->sendRequestThroughRouter($request);
         }
     } catch (Exception $exception) {
         $this->exception->report($exception);
         return $this->exception->handle($exception);
     }
     return $next($request);
 }
コード例 #3
0
ファイル: Router.php プロジェクト: laravie/api
 /**
  * Dispatch a request via the adapter.
  *
  * @param \Dingo\Api\Http\Request $request
  *
  * @throws \Exception
  *
  * @return \Dingo\Api\Http\Response
  */
 public function dispatch(Request $request)
 {
     $this->currentRoute = null;
     $this->container->instance('Dingo\\Api\\Http\\Request', $request);
     $this->routesDispatched++;
     try {
         $response = $this->adapter->dispatch($request, $request->version());
         if (property_exists($response, 'exception') && $response->exception instanceof Exception) {
             throw $response->exception;
         }
     } catch (Exception $exception) {
         if ($request instanceof InternalRequest) {
             throw $exception;
         }
         $this->exception->report($exception);
         $response = $this->exception->handle($exception);
     }
     return $this->prepareResponse($response, $request, $request->format());
 }