public function run()
    {
        $url = parse_url($_SERVER['REQUEST_URI']);

        $controller = $this->router->find($url['path']);
        if (!$controller instanceof ControllerInterface) {
            throw new \RuntimeException('No valid controller found.');
        }

        $controller->setServer($this);

        $result = $controller->execute();

        $data = json_encode($result);

        if (array_key_exists('callback', $_GET)) {
            $data = $_GET['callback'] . '(' . $data . ')';
        }
        
        return $data;
    }