dispatch() public method

Dispatch a request via the adapter.
public dispatch ( Dingo\Api\Http\Request $request ) : Response
$request Dingo\Api\Http\Request
return Dingo\Api\Http\Response
Esempio n. 1
0
 /**
  * Send the request through the Dingo router.
  *
  * @param \Dingo\Api\Http\Request $request
  *
  * @return \Dingo\Api\Http\Response
  */
 protected function sendRequestThroughRouter(HttpRequest $request)
 {
     $this->app->instance('request', $request);
     return (new Pipeline($this->app))->send($request)->through($this->middleware)->then(function ($request) {
         return $this->router->dispatch($request);
     });
 }
 /**
  * Attempt to dispatch an internal request.
  *
  * @param  \Dingo\Api\Http\InternalRequest  $request
  * @return mixed
  * @throws \Exception|\Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
  */
 protected function dispatch(InternalRequest $request)
 {
     $this->routeStack[] = $this->router->getCurrentRoute();
     try {
         $response = $this->router->dispatch($request);
         if (!$response->isSuccessful()) {
             throw new HttpException($response->getStatusCode(), $response->getOriginalContent());
         }
     } catch (HttpExceptionInterface $exception) {
         $this->refreshRequestStack();
         throw $exception;
     }
     $this->refreshRequestStack();
     return $response->getOriginalContent();
 }
Esempio n. 3
0
 /**
  * Attempt to dispatch an internal request.
  *
  * @param \Dingo\Api\Http\InternalRequest $request
  *
  * @throws \Exception|\Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
  *
  * @return mixed
  */
 protected function dispatch(InternalRequest $request)
 {
     $this->routeStack[] = $this->router->getCurrentRoute();
     $this->clearCachedFacadeInstance();
     try {
         $response = $this->router->dispatch($request);
         if (!$response->isSuccessful()) {
             throw new InternalHttpException($response);
         } elseif (!$this->raw) {
             $response = $response->getOriginalContent();
         }
     } catch (HttpExceptionInterface $exception) {
         $this->refreshRequestStack();
         throw $exception;
     }
     $this->refreshRequestStack();
     return $response;
 }