Dispatch a request via the adapter.
public dispatch ( Dingo\Api\Http\Request $request ) : |
||
$request | Dingo\Api\Http\Request | |
Résultat |
/** * 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(); }
/** * 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; }