Inheritance: use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\StdLib\StdLibTrait
Exemplo n.º 1
0
 /**
  * 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;
     }
 }
Exemplo n.º 2
0
 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']);
 }
Exemplo n.º 3
0
 /**
  * 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);
         return $router->processRequest();
     } catch (\Exception $e) {
         throw new RestException('Unable to process request for class "' . $this->class . '". ' . $e->getMessage());
     }
 }