Run the application and dispatch the router

@param  string   $method
@param  string   $path
194739
public function run($method = null, $path = null)
    {
        $method = $method ?: $this->request->getMethod();
        $path   = $path ?: $this->request->currentPath();

        $this->dispatchRouter($method, $path)->send();
    }
74750
public Routed<Object> route(M method, String path) {
    return router.route(method, path);
  }
120694
public function route($method, $path, $callback)
    {
        Argument::i()
            //argument 1 should be a string
            ->test(1, 'string')
            //argument 2 should be a string
            ->test(2, 'string')
            //argument 3 should be callable
            ->test(3, 'callable');
        
        $method = strtoupper($method);
        
        if ($method === 'ALL') {
            return $this
                ->route('get', $path, $callback)
                ->route('post', $path, $callback)
                ->route('put', $path, $callback)
                ->route('delete', $path, $callback);
        }
        
        $this->routeMiddleware[$method][] = array($path, $callback);
        
        return $this;
    }
536722
public static function addRoute($path, $target, $method = 'GET')
    {
        $router = Router::getInstance();
        $router->altoRouter->map($method, $path, $target);
    }
400629
public function any(string $path, $handler, array $pathParams = [], array $opts = []): void
    {
        $this->map(self::METHODS_ARRAY, $path, $handler, $pathParams, $opts);
    }
803374
public function when(string $path, $listener): void
    {
        $this->whenOn($path, RouteMatched::class, $listener);
    }
829210
public function addRoute($method, $path, $action)
    {
        $route = (new Route($this->conditions, $this->container))
            ->setMethods($method)
            ->setPath($path)
            ->setAction($action)
            ->setRouter($this);

        return $this->routes->add($route);
    }
884242
protected function runAuthorizesWithApiKeyTasks($method, &$path, &$options, &$withAuthorization)
    {
        // By default, we append the authorization header to every request.
        if ($withAuthorization) {
            $authorizationHeader = $this->getAuthorizationHeader();
            $options['headers'] = array_merge($this->defaultHeaders, $options['headers'], $authorizationHeader);
        }
    }
553934
public function dispatch($path = '/', $method = 'GET')
    {
        foreach ($this->rules as $rule)
        {
            if ($rule->matching($path, $method))
                return $rule->toActionCaller($path, $method);
        }
        throw new NotFoundException($path);
    }
1259863
public function dispatch($method = null, $path = null)
    {
        $match = $this->getMatch($method, $path);

        foreach ($match->before as $filter) {
            if (empty($filter)) {
                continue;
            }
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        $routeResponse = $this->executeCallback($match->callback, $match->args);

        foreach ($match->after as $filter) {
            if (empty($filter)) {
                continue;
            }
            array_unshift($match->args, $routeResponse);
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        return $routeResponse;
    }
1078196
protected function dispatchRouter($method, $path)
    {
        $resolver   = $this->make('Glue\Router\RouterResolver');
        $dispatcher = new Dispatcher($this->router->getData(), $resolver);

        $httpCode = Response::HTTP_OK;
        $allow    = null;

        try {

            $response = $dispatcher->dispatch($method, $path);
            if ($response instanceof Response) {
                $httpCode = $response->getStatusCode();
            }

        } catch(HttpRouteNotFoundException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_NOT_FOUND);
            $httpCode = Response::HTTP_NOT_FOUND;

        } catch(HttpMethodNotAllowedException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_METHOD_NOT_ALLOWED);
            $httpCode = Response::HTTP_METHOD_NOT_ALLOWED;
            if (strpos($e->getMessage(), 'Allow:') === 0) {
                // We got an Allow-message as exception message.
                // Save it so we can add it to the response header
                $allow = trim(explode(':', $e->getMessage())[1]);
            }

        } catch(\Exception $e) {

            if ($this->bound('Psr\Log\LoggerInterface')) {
                $this->make('Psr\Log\LoggerInterface')
                    ->critical($e->getMessage(), [__METHOD__]);
            }

            throw $e;

        }

        if (!$response instanceof Response) {
            $response = new Response((string) $response);
            $response->setStatusCode($httpCode);
        }

        if ($allow) {
            $response->headers->set('Allow', $allow);
        }

        return $response;
    }
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();
    }
659567
public function run(
        string $method,
        string $uri,
        array $headers,
        string $body
    ) {
        if ($this->router === null) {
            return;
        }

        try {
            $response = $this->router->run($method, $uri, $headers, $body);
            if ($response !== null) {
                $response->output();
            }
        } catch (RouterException $e) {
            $e->getResponse()->output();
        }
    }
341598
public function dispatch(Route $route, $controller, $method)
    {
        $parameters = $this->resolveClassMethodDependencies(
            $route->parametersWithoutNulls(), $controller, $method
        );

        if (method_exists($controller, 'callAction')) {
            return $controller->callAction($method, $parameters);
        }

        return call_user_func_array(array($controller, $method), $parameters);
    }
506967
private function executeRoute(Route &$route, $method, $force = false)
    {
        $continue = true;
        if (! $force) {
            $continue = $this->executeRouteMiddleware($route, 'before', $method);
        }

        if ($continue === true) {
            $route->execute($this->compiled);
        }

        if (! $force) {
            $this->executeRouteMiddleware($route, 'after', $method);
        }
    }
1206248
public function route(
		$path, $callback, $method='GET', $is_raw=null
	) {
		$this->core->route($path, function($args) use($callback){
			# set token if available
			if (isset($args['cookie'][$this->token_name])) {
				# via cookie
				$this->adm_set_user_token(
					$args['cookie'][$this->token_name]);
			} elseif (isset($args['header']['authorization'])) {
				# via request header
				$auth = explode(' ', $args['header']['authorization']);
				if (count($auth) == 2 && $auth[0] == $this->token_name) {
					$this->adm_set_user_token($auth[1]);
				}
			}
			# execute calback
			$callback($args);
		}, $method, $is_raw);
	}
148495
protected function run($method, $args) {
		$request = $this->request();
		$request->method($method);
		$request->resource(array_shift($args));
		if (count($args)) {
			$request->params(array_shift($args));
		}
		if (count($args)) {
			$request->files(array_shift($args));
		}
		return $request->send();
	}