Run Application
@param  String $route Route to parse
@return void
483024
public function run($route = null) {

        $self = $this;

        if ($route) {
            $this->registry['route'] = $route;
        }

        register_shutdown_function(function() use($self){

            if ($self->isExit()){
                return;
            }

            $error = error_get_last();

            if ($error && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR])){

                ob_end_clean();

                $self->response->status = '500';
                $self->response->body   = $self['debug'] ? json_encode($error, JSON_PRETTY_PRINT):'Internal Error.';

            } elseif (!$self->response->body && !is_string($self->response->body) && !is_array($self->response->body)) {
                $self->response->status = '404';
                $self->response->body   = 'Path not found.';
            }

            $self->trigger('after');

            echo $self->response->flush();

            $self->trigger('shutdown');
        });

        $this->response = new Response();
        $this->trigger('before');
        $this->response->body = $this->dispatch($this->registry['route']);

        if ($this->response->gzip && !ob_start('ob_gzhandler')) ob_start();
    }
121834
final public function run(Request $request)
    {
        $this->request = $request;
        $path = $this->request->getUri()->getPath();
        $this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/";
        $this->requestedMethod = strtoupper($this->request->getMethod());
        $this->requestedRepresentation = $this->request->getAccept();
        $this->verifyRequestMethod();
        $route = $this->findRouteFromRequest();
        $this->prepareResponse($route);
    }
1182515
public function execute($route, array $parameters = array(), \Exedra\Http\ServerRequest $request = null)
    {
        $route = $this->baseRoute($route);

        $request = $request ? : $this->request;

        return $this->app->execute($route, $parameters, $request);
    }
1005921
public static function post($route)
    {
        $content = self::traitPost($route);
        //
        self::addRoute($content);

        return true;
    }
745636
public function run()
    {
        $documentRoot = realpath($_SERVER['DOCUMENT_ROOT']);
        $getCwd = realpath(getcwd());

        $base = str_replace('\\', '/', str_replace($documentRoot, '', $getCwd) . '/');
        $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

        if (($base !== $uri) && (substr($uri, -1) === '/')) {
            $uri = substr($uri, 0, (strlen($uri)-1));
        }

        if ($uri === '') {
            $uri = '/';
        }

        $method = RouterRequest::getRequestMethod();
        $searches = array_keys($this->patterns);
        $replaces = array_values($this->patterns);
        $foundRoute = false;

        $routes = [];
        foreach ($this->routes as $data) {
            array_push($routes, $data['route']);
        }

        // check if route is defined without regex
        if (in_array($uri, array_values($routes))) {
            foreach ($this->routes as $data) {
                if (RouterRequest::validMethod($data['method'], $method) && ($data['route'] === $uri)) {
                    $foundRoute = true;
                    $this->runRouteMiddleware($data, 'before');
                    $this->runRouteCommand($data['callback']);
                    $this->runRouteMiddleware($data, 'after');
                    break;
                }
            }
        } else {
            foreach ($this->routes as $data) {
                $route = $data['route'];

                if (strpos($route, '{') !== false) {
                    $route = str_replace($searches, $replaces, $route);
                }

                if (preg_match('#^' . $route . '$#', $uri, $matched)) {
                    if (RouterRequest::validMethod($data['method'], $method)) {
                        $foundRoute = true;

                        $this->runRouteMiddleware($data, 'before');

                        array_shift($matched);
                        $newMatched = [];
                        foreach ($matched as $key => $value) {
                            if (strstr($value, '/')) {
                                foreach (explode('/', $value) as $k => $v) {
                                    $newMatched[] = trim(urldecode($v));
                                }
                            } else {
                                $newMatched[] = trim(urldecode($value));
                            }
                        }
                        $matched = $newMatched;

                        $this->runRouteCommand($data['callback'], $matched);
                        $this->runRouteMiddleware($data, 'after');
                        break;
                    }
                }
            }
        }

        // If it originally was a HEAD request, clean up after ourselves by emptying the output buffer
        if (strtoupper($_SERVER['REQUEST_METHOD']) === 'HEAD') {
            ob_end_clean();
        }

        if ($foundRoute === false) {
            if (! $this->errorCallback) {
                $this->errorCallback = function() {
                    header($_SERVER['SERVER_PROTOCOL']." 404 Not Found");
                    return $this->exception('Route not found. Looks like something went wrong. Please try again.');
                };
            }
            call_user_func($this->errorCallback);
        }
    }
167300
private function runView(): void
    {
        $action = ($this->routeAction) ? $this->routeAction : 'index';

        \call_user_func([$this->view, $action]);
    }
1131359
public static function performRoute($route) {
		$api_mode = isset($route["api-mode"]);
		Request::setRequestVariables($route["variables"], $api_mode);

		$controller = new $route["class"];
		$response = $controller->$route["method"]();

		if(!Request::isAjax() && !Request::isAPI() && isset($route["render-path"])) {
			Request::setRenderPath($route["render-path"]);
			try {
				$route = self::findRoute(explode('/', $route["render-path"]));
			} catch(ValidRouteNotFoundException $e) {
				throw new ValidRenderRouteNotFoundException($e);
			}
			$response = self::performRoute($route);
		}

		return $response;
	}
596884
public function processRoutes($routes)
	{
		if (is_null($this->openAPI->paths)) {
			$this->openAPI->paths = [];
		}

		foreach ($routes as $route) {
			$this->processRoute($route);
		}

	}
1320495
public function run()
    {
        $request = $this->request;
        $response = $this->response;
        $config = $this->configuration;

        $httpMethod = $request->getMethod();
        $pathInfo = $request->getUri()->getPath();
        if (empty($pathInfo)) {
            $pathInfo = '/';
        }

        $routeObject = $this->router->resolve($pathInfo, $httpMethod);
        if($routeObject) {
            $middlewareList = [];
            if (isset($routeObject['middleware'])) {
                $middlewareConfig = $config->get('middlewares');
                $middlewareCount = count($routeObject['middleware']);
                $middlewareNext = null;
                $middlewareFactory = $this->container->get(MiddlewareFactory::class);

                for ($i=$middlewareCount-1; $i >= 0; $i--) {
                    $middlewareName = $routeObject['middleware'][$i];
                    $middlewareClass = $middlewareConfig[$middlewareName];
                    $middlewareList[$i] = $middlewareFactory->createObject($middlewareClass, [
                        'response' => $response,
                        'next' => $middlewareNext,
                    ]);
                    $middlewareNext = $middlewareList[$i];
                }
            }

            $baseNamespace = $config->get('controllersNamespace');
            $handler = $this->convertCallbackToClosure($routeObject['handler'], $baseNamespace);
            $params = isset($routeObject['params']) ? $routeObject['params'] : [];
            $requestHandler = new ServerRequestHandler($response, $handler, $routeObject['params']);

            if (isset($middlewareList[0])) {
                $response = $middlewareList[0]->process($request, $requestHandler);
            } else {
                $response = $requestHandler->handle($request);
            }

        } else {
            throw new HttpException(404, "Route '{$pathInfo}' not found");
        }

        $this->emitResponse($response);
    }
347604
function run() {
		if ($this->blacklisted($this->hive['IP']))
			// Spammer detected
			$this->error(403);
		if (!$this->hive['ROUTES'])
			// No routes defined
			user_error(self::E_Routes,E_USER_ERROR);
		// Match specific routes first
		$paths=array();
		foreach ($keys=array_keys($this->hive['ROUTES']) as $key)
			$paths[]=str_replace('@','*@',$key);
		$vals=array_values($this->hive['ROUTES']);
		array_multisort($paths,SORT_DESC,$keys,$vals);
		$this->hive['ROUTES']=array_combine($keys,$vals);
		// Convert to BASE-relative URL
		$req=$this->rel($this->hive['URI']);
		if ($cors=(isset($this->hive['HEADERS']['Origin']) &&
			$this->hive['CORS']['origin'])) {
			$cors=$this->hive['CORS'];
			header('Access-Control-Allow-Origin: '.$cors['origin']);
			header('Access-Control-Allow-Credentials: '.
				($cors['credentials']?'true':'false'));
		}
		$allowed=array();
		foreach ($this->hive['ROUTES'] as $pattern=>$routes) {
			if (!$args=$this->mask($pattern,$req))
				continue;
			ksort($args);
			$route=NULL;
			if (isset(
				$routes[$ptr=$this->hive['AJAX']+1][$this->hive['VERB']]))
				$route=$routes[$ptr];
			elseif (isset($routes[self::REQ_SYNC|self::REQ_AJAX]))
				$route=$routes[self::REQ_SYNC|self::REQ_AJAX];
			if (!$route)
				continue;
			if ($this->hive['VERB']!='OPTIONS' &&
				isset($route[$this->hive['VERB']])) {
				$parts=parse_url($req);
				if ($this->hive['VERB']=='GET' &&
					preg_match('/.+\/$/',$parts['path']))
					$this->reroute(substr($parts['path'],0,-1).
						(isset($parts['query'])?('?'.$parts['query']):''));
				list($handler,$ttl,$kbps,$alias)=$route[$this->hive['VERB']];
				if (is_bool(strpos($pattern,'/*')))
					foreach (array_keys($args) as $key)
						if (is_numeric($key) && $key)
							unset($args[$key]);
				// Capture values of route pattern tokens
				$this->hive['PARAMS']=$args=array_map('urldecode',$args);
				// Save matching route
				$this->hive['ALIAS']=$alias;
				$this->hive['PATTERN']=$pattern;
				if ($cors && $cors['expose'])
					header('Access-Control-Expose-Headers: '.(is_array($cors['expose'])?
						implode(',',$cors['expose']):$cors['expose']));
				if (is_string($handler)) {
					// Replace route pattern tokens in handler if any
					$handler=preg_replace_callback('/@(\w+\b)/',
						function($id) use($args) {
							return isset($args[$id[1]])?$args[$id[1]]:$id[0];
						},
						$handler
					);
					if (preg_match('/(.+)\h*(?:->|::)/',$handler,$match) &&
						!class_exists($match[1]))
						$this->error(404);
				}
				// Process request
				$result=NULL;
				$body='';
				$now=microtime(TRUE);
				if (preg_match('/GET|HEAD/',$this->hive['VERB']) && $ttl) {
					// Only GET and HEAD requests are cacheable
					$headers=$this->hive['HEADERS'];
					$cache=Cache::instance();
					$cached=$cache->exists(
						$hash=$this->hash($this->hive['VERB'].' '.
							$this->hive['URI']).'.url',$data);
					if ($cached && $cached[0]+$ttl>$now) {
						if (isset($headers['If-Modified-Since']) &&
							strtotime($headers['If-Modified-Since'])+
								$ttl>$now) {
							$this->status(304);
							die;
						}
						// Retrieve from cache backend
						list($headers,$body,$result)=$data;
						if (PHP_SAPI!='cli')
							array_walk($headers,'header');
						$this->expire($cached[0]+$ttl-$now);
					}
					else
						// Expire HTTP client-cached page
						$this->expire($ttl);
				}
				else
					$this->expire(0);
				if (!strlen($body)) {
					if (!$this->hive['RAW'] && !$this->hive['BODY'])
						$this->hive['BODY']=file_get_contents('php://input');
					ob_start();
					// Call route handler
					$result=$this->call($handler,array($this, $args),
						'beforeroute,afterroute');
					$body=ob_get_clean();
					// Template Parsing
					if ($this->hive['TEMPLATE']) {
						$this->hive['RESPONSE'] = $body;
						$body = $this->send($this->hive['TEMPLATE'], true);
					}
					if (isset($cache) && !error_get_last()) {
						// Save to cache backend
						$cache->set($hash,array(
							// Remove cookies
							preg_grep('/Set-Cookie\:/',headers_list(),
								PREG_GREP_INVERT),$body,$result),$ttl);
					}
				}
				$this->hive['RESPONSE']=$body;
				if (!$this->hive['QUIET']) {
					if ($kbps) {
						$ctr=0;
						foreach (str_split($body,1024) as $part) {
							// Throttle output
							$ctr++;
							if ($ctr/$kbps>($elapsed=microtime(TRUE)-$now) &&
								!connection_aborted())
								usleep(1e6*($ctr/$kbps-$elapsed));
							echo $part;
						}
					}
					else
						echo $body;
				}
				return $result;
			}
			$allowed=array_merge($allowed,array_keys($route));
		}
		if (!$allowed)
			// URL doesn't match any route
			$this->error(404);
		elseif (PHP_SAPI!='cli') {
			// Unhandled HTTP method
			header('Allow: '.implode(',',array_unique($allowed)));
			if ($cors) {
				header('Access-Control-Allow-Methods: OPTIONS,'.implode(',',$allowed));
				if ($cors['headers'])
					header('Access-Control-Allow-Headers: '.(is_array($cors['headers'])?
						implode(',',$cors['headers']):$cors['headers']));
				if ($cors['ttl']>0)
					header('Access-Control-Max-Age: '.$cors['ttl']);
			}
			if ($this->hive['VERB']!='OPTIONS')
				$this->error(405);
		}
		return FALSE;
	}
1018928
function create($route) {
        $route->pattern = $this->parser->trimPath($route->pattern);
        return parent::create($route);
    }
257393
protected function processRoute($route)
    {
        //ancestors
        //loop route parameters to get ancestors
        foreach($route['parameters'] as $parameter => $value) {
            preg_match('/ancestor[0-9]+/', $parameter, $matches, PREG_OFFSET_CAPTURE);
            if(!empty($matches)) {
                $this->ancestors[$value] = [];
            }
        }
        //loop ancestors to get primary keys values
        foreach($this->ancestors as $subject => $primaryKey) {
            //require ancestor configuration
            $configuration = self::getConfiguration($subject);
            //load ancestor translations
            //locale
            if(isset($configuration['locale']) && $configuration['locale']) {
                $this->loadApplicationTranslations($subject, $configuration['locale']);
            }
            //loop primary key values
            $primaryKey = $configuration['ORM']['primaryKey'];
            $primaryKey = is_array($primaryKey) ? $primaryKey : [$primaryKey];
            foreach($primaryKey as $field) {
                //check field into route parameters
                if(!isset($route['parameters'][$field])) {
                    throw new \Exception(sprintf('Current route contains subject %s as ancestor but does not contain parameter for primary key field %s', $ancestor['subject'], $field));
                }
                //store field value
                $this->ancestors[$subject][$field] = $route['parameters'][$field];
            }
        }
        //subject
        if(isset($route['properties']['subject'])) {
            $route['parameters']['subject'] = $route['properties']['subject'];
        }
        //extract action
        //static set action first
        if(isset($route['properties']['action'])) {
            $this->action = $route['properties']['action'];
        //action into URL otherwise
        } else if(isset($route['parameters']['action'])) {
            $this->action = $route['parameters']['action'];
        }
        //traits
        $traits = $this->getUsedTraits();
        $reflection = new \ReflectionClass($this);
        foreach($traits as $trait) {
            $methodName = 'processRouteTrait' . $trait;
            if($reflection->hasMethod($methodName)) {
                $this->$methodName($route);
            }
        }
        //store
        $this->route = $route;
    }
871859
public function run()
    {
        $templatePath = $this->customTemplate ?: __DIR__."/template/route.blade.php";

        $module  = camel_case($this->module);
        $model   = camel_case($this->model);

        $view =  View::file($templatePath, [
            "group"         => $this->group,
            "module"        => $module,
            "model"         => $model,
        ]);

        $routeFile = file_get_contents(base_path("routes/web.php"));

        if(strpos($routeFile, ucfirst($module)."Controller@".lcfirst($model)."Lists") === false)
        {
            file_put_contents(base_path("routes/web.php"), str_replace("#", "@", $view->render()), FILE_APPEND);
        }
    }
1339232
public function route($request)
    {
        if (!self::$_cli) {
            $router = $this->get('routing');
            $router->route($request);
        }
    }
761921
public function run(&$request)
    {
        $this->detect($request);
        $request = $this->driver->formatIncomingRequest($request);
    }
687710
function run()
    {
        $request  = $this->getServerRequest();
        $response = $this->getResponse();
        $uri      = $request->getUri();
        $basepath = $uri->getBasePath();
        $args     = explode('/', htmlspecialchars($basepath));

        $response = $this->process($request, $response, $args);

        $this->finalize($request, $response, $args);
    }
421127
private function run(string $url, array $route)
    {
        if ($url == $route[0]) {


            $class = "App\\Controllers\\".ucfirst($route[1]);

            if (!class_exists($class)) {

                $error = new Error();
                $error->errorMessage("Error: classe não existe. Verifique seu arquivo web.php ou na pasta App/Controllers.");
                exit();

            }

            $instance = new $class;

            $action = $route[2];

            if (method_exists($instance, $action)) {

                $instance->$action();

            } else {

                $error = new Error();
                $error->errorMessage("Error: método não existe. Verifique no arquivo web.php ou na sua classe.");

            }

        } else {

            $this->urlError++;

        }
    }