public static function initRest($api, $url = '', $method = '')
    {
        $config = self::getConfig()->get($api, false);

        if (!$config) {
            throw new RestException('Configuration for "' . $api . '" not found.');
        }

        // check if we have the Path defined
        $path = $config->get('Router.Path', false);
        if (!$path) {
            throw new RestException('Router.Path is not defined for "' . $api . '" api.');
        }

        // create the route for Router component
        $route = [
            'WebinyRest' . $api => [
                'Path'     => self::str($path)->trimRight('/')->append('/{webiny_rest_params}')->val(),
                'Callback' => 'null',
                'Options'  => [
                    'webiny_rest_params' => [
                        'Pattern' => '.*?'
                    ]
                ]
            ]
        ];

        // call the router and match the request
        // we must append some dummy content at the end of the url, because in case of a default API method, and since
        // we have added an additional pattern to the url, the url will not match
        self::router()->prependRoutes(new ConfigObject($route));
        if ($url == '') {
            $result = self::router()->match(self::str(self::httpRequest()->getCurrentUrl(true)->getPath())
                                                ->trimRight('/')
                                                ->append('/_w_rest/_foo')
                                                ->val());
        } else {
            $result = self::router()->match(self::str($url)->trimRight('/')->append('/_w_rest/_foo')->val());
        }

        if (!$result) {
            return false;
        }

        self::$url = $url;
        self::$method = $method;

        return self::processRouterResponse($result, $config, $api);
    }