private function matchMethod($callbacks, $url)
    {
        // match a callback based on url pattern
        $methodData = false;
        $matchedParameters = false;

        // match method
        foreach ($callbacks as $pattern => $data) {
            if (($matchedParameters = $this->doesPatternMatch($pattern, $data, $url)) !== false) {
                $methodData = $data;
                break;
            } else if ($data['resourceNaming'] === false) {
                $matchedParameters = $this->tryMatchingOptionalParams($pattern, $data, $url);
                if ($matchedParameters) {
                    $methodData = $data;
                    break;
                }
            }
        }

        return [
            'methodData'        => $methodData,
            'matchedParameters' => $matchedParameters
        ];
    }