_apiConfig = $apiConfig; } /** * Route the Request, the only responsibility of the class. * Find route that matches current URL, set parameters of the route to Request object. * * @param Request $request * @return \Magento\Webapi\Controller\Rest\Router\Route * @throws \Magento\Framework\Webapi\Exception */ public function match(Request $request) { /** @var \Magento\Webapi\Controller\Rest\Router\Route[] $routes */ $routes = $this->_apiConfig->getRestRoutes($request); $matched = []; foreach ($routes as $route) { $params = $route->match($request); if ($params !== false) { $request->setParams($params); $matched[] = $route; } } if (!empty($matched)) { return array_pop($matched); } throw new \Magento\Framework\Webapi\Exception( __('Request does not match any route.'), 0, \Magento\Framework\Webapi\Exception::HTTP_NOT_FOUND ); } }