/**
  * 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);
 }
 /**
  * @expectedException \Magento\Framework\Webapi\Exception
  */
 public function testNotMatch()
 {
     $this->_apiConfigMock->expects($this->once())->method('getRestRoutes')->will($this->returnValue([$this->_routeMock]));
     $this->_routeMock->expects($this->once())->method('match')->with($this->_request)->will($this->returnValue(false));
     $this->_router->match($this->_request);
 }