public function dispatch()
 {
     $url = $this->system->getConfig()->getRequestUrl();
     $url = preg_replace("!\\?.*\$!", '', $url);
     $url = urldecode($url);
     $r = $this->dispatchRoutes($this->getRoutes(), $url);
     if (!$r || $r['url'] == '*' && $url && strpos(substr($url, -5), '.') === false && substr($url, -1) !== '/') {
         $r2 = $this->dispatchRoutes($this->getRoutes(), $url . '/');
         if ($r2 && (!$r || $r2['url'] != '*')) {
             $this->system->getResponse()->redirect($this->system->getRootUrl() . $url . '/');
         }
     }
     // if route found and app exists
     if ($r && isset($r['app']) && $r['app'] && $this->system->appExists($r['app'])) {
         $this->setRoute($r);
         // dispatch app routes
         $params = waRequest::param();
         $u = $r['url'];
         if (preg_match_all('/<([a-z_]+):?([^>]*)?>/ui', $u, $match, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
             $offset = 0;
             foreach ($match as $m) {
                 $v = $m[1][0];
                 $s = isset($params[$v]) ? $params[$v] : '';
                 $u = substr($u, 0, $m[0][1] + $offset) . $s . substr($u, $m[0][1] + $offset + strlen($m[0][0]));
                 $offset += strlen($s) - strlen($m[0][0]);
             }
         }
         $this->root_url = self::clearUrl($u);
         $url = substr($url, strlen($this->root_url));
         $this->dispatchRoutes($this->getAppRoutes($r['app'], $r), $url);
     }
     return $r;
 }
 public function meta($name, $value = null)
 {
     if ($value) {
         $this->wa->getResponse()->setMeta($name, $value);
     } else {
         return $this->wa->getResponse()->getMeta($name);
     }
 }