public function testResourceNamingWithParams() { $url = 'http://api.example.com/mock-api-class-router/some-url/123/name/John Snow'; $r = new Router('ExampleApi', 'Webiny\\Component\\Rest\\Tests\\Mocks\\MockApiClassRouter', true, self::$cache); $r->setUrl($url); $r->setHttpMethod('get'); $result = $r->processRequest(); $this->assertSame('123 => John Snow', $result->getOutput()['data']); }
/** * Processes the current request and returns an instance of CallbackResult. * * @return bool|Response\CallbackResult * @throws RestException */ public function processRequest() { try { $router = new Router($this->api, $this->class, $this->normalize, $this->cacheInstance); // check if url is set via the initRest method if (!empty(self::$url)) { $router->setUrl(self::$url); } // check if the method vas set via initRest method if (!empty(self::$method)) { $router->setHttpMethod(self::$method); } return $router->processRequest(); } catch (\Exception $e) { $exception = new RestException('Unable to process request for class "' . $this->class . '". ' . $e->getMessage()); $exception->setRequestedClass($this->class); throw $exception; } }