public function parseRoute($beforeDispatch)
    {

        //echo '1. Check the request; <br/>2. $response =  $this->sync(); //to get a synchronous response; <br/>3. $response->send();<br />';

        //print_R($this->observer->getListeners('Dispatcher.beforeDispatch'));

        //var_dump($this->router);
        //var_dump($beforeDispatch->get('data'));
        $request = $this->application->request;

        $route = $this->router->matchToRoute($request);

        if (!($route instanceof Route)) {
            throw new Exception("A valid route could not be determined");
        }
        $format = "html";
        //clean up format
        if (isset($route->params['format'])) {
            $format = str_replace([".", " ", "_", "-"], "", $route->params['format']);

        }
        $route->setParam("format", $format);


        $request->setAttributes($route->params);

        //Store the route in the event data
        $beforeDispatch->data['route'] = $route;

    }