Webiny\Component\Rest\Response\Router::setUrl PHP Method

setUrl() public method

In case a fixed url string is passed directly into the Rest instance, using this method the url will be passed to the router.
public setUrl ( string $url )
$url string Url upon which we will try to match a service in the registered class.
    public function setUrl($url)
    {
        $url = $this->url($url)->getPath();
        $this->url = $this->str($url)->trimRight('/')->val() . '/';
    }

Usage Example

Exemplo n.º 1
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']);
 }
All Usage Examples Of Webiny\Component\Rest\Response\Router::setUrl