PHP Class Webiny\Component\Rest\Response\Router

Inheritance: use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( string $api, string $class, boolean $normalize, Cache $compilerCache ) Base constructor.
getMethod ( ) : string Get the http method.
getUrl ( ) : string Returns the current url path.
processRequest ( ) : CallbackResult Process the api rest request and return the CallbackResult object.
setHttpMethod ( string $method ) Force sets the http method.
setUrl ( string $url ) Set the url.

Private Methods

Method Description
doesPatternMatch ( string $pattern, array $data, string $url ) : boolean Checks if $pattern matches $url.
getVersion ( ) : string Check if there is a specific version set in the request headers, if not, it returns 'current' version.
matchDefaultMethod ( array $callbacks, string $url, $classUrl ) : array This is the fallback method that tries to match a default method.
matchMethod ( array $callbacks, string $url ) : array Does the matching of method if method name is present in the url.
matchRequest ( array &$classData ) : CallbackResult Analyzes the request and tries to match an api method.
tryMatchingOptionalParams ( string $pattern, array $data, string $url ) : boolean This method adds the default values for missing parameters and tries to do the match again.

Method Details

__construct() public method

Base constructor.
public __construct ( string $api, string $class, boolean $normalize, Cache $compilerCache )
$api string Name of the rest api configuration.
$class string Name of the rest api class.
$normalize boolean Should the url parts be normalized or not.
$compilerCache Webiny\Component\Rest\Compiler\Cache Current compiler cache instance.

getMethod() public method

Get the http method.
public getMethod ( ) : string
return string

getUrl() public method

Returns the current url path.
public getUrl ( ) : string
return string

processRequest() public method

Process the api rest request and return the CallbackResult object.
public processRequest ( ) : CallbackResult
return CallbackResult

setHttpMethod() public method

Force sets the http method.
public setHttpMethod ( string $method )
$method string Method name.

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.