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

setHttpMethod() public method

Force sets the http method.
public setHttpMethod ( string $method )
$method string Method name.
    public function setHttpMethod($method)
    {
        $method = strtolower($method);
        if (!in_array($method, self::$supportedRequestTypes)) {
            throw new RestException('The provided HTTP is no supported: "' . $method . '".');
        }
        $this->method = $method;
    }

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::setHttpMethod