router

this router will call action methods for normal requests,
and REST methods for RESTful calls

@param  string
@param  array
174566
public function router($resource, $arguments)
	{
		// if this is an ajax call
		if ($this->is_restful())
		{
			// have the Controller_Rest router deal with it
			return parent::router($resource, $arguments);
		}

		// check if a input specific method exists
		$controller_method = strtolower(\Input::method()) . '_' . $resource;

		// fall back to action_ if no rest method is provided
		if ( ! method_exists($this, $controller_method))
		{
			$controller_method = 'action_'.$resource;
		}

		// check if the action method exists
		if (method_exists($this, $controller_method))
		{
			return call_fuel_func_array(array($this, $controller_method), $arguments);
		}

		// if not, we got ourselfs a genuine 404!
		throw new \HttpNotFoundException();
	}
1339232
public function route($request)
    {
        if (!self::$_cli) {
            $router = $this->get('routing');
            $router->route($request);
        }
    }
919567
public function createDefaultPageRoutes(IRouter $routes, string $url): void
	{
		if ($this->configurator->onePage) {
			$routes[] = new Route($url, $this->onePageLink);
			$routes[] = new Route($url . 'index.php', $this->onePageLink, Route::ONE_WAY);
			$routes[] = new Route($url . '<presenter>[/<action>]', $this->defaultLink);

		} else {
			$routes[] = new Route($url, $this->defaultLink);
			$routes[] = new Route($url . 'index.php', $this->defaultLink, Route::ONE_WAY);
			$routes[] = new Route($url . '<presenter>[/<action>]', $this->defaultLink);
		}
	}
4138
private static function routeAction()
    {
        $actionQueryString = Request::getInputValue("do", false, true);
        $actionQuery = Actions::parseActionQueryString($actionQueryString);
        
        Addons::executeComponentFunction($actionQuery->name, $actionQuery->method, @$actionQuery->arguments);
    }
862229
public static function __callstatic($method, $params) {

    if ($method == 'map') {
        $maps = array_map('strtoupper', $params[0]);
        $uri = strpos($params[1], '/') === 0 ? $params[1] : '/' . $params[1];
        $callback = $params[2];
    } else {
        $maps = null;
        $uri = strpos($params[0], '/') === 0 ? $params[0] : '/' . $params[0];
        $callback = $params[1];
    }

    array_push(self::$maps, $maps);
    array_push(self::$routes, $uri);
    array_push(self::$methods, strtoupper($method));
    array_push(self::$callbacks, $callback);
  }
468833
public function addRoutes(array $routes)
    {
        foreach ($routes as $route => $endpoint) {
            // Add route as key. Use rtrim to remove any existing trailing slash, and then
            // add a new trailing slash
            $route = ($route !== '/') ? rtrim($route, '/') : '/';
            $this->routes[$route] = $endpoint;
        }
    }
1027347
public function addRoute($methods, string $pattern, string $handler)
    {
        if (is_string($methods)) {
            $methods = (array) $methods;
        }

        $methods = array_map('strtoupper', $methods);

        $this->routes[] = [
            $methods,
            $pattern,
            $handler
        ];
    }
936706
function (methods) {
    this.lazyRouter();
    this.router.method(methods);
    utils.arrayify(methods).forEach(function (method) {
      this.define(method, function(path) {
        var route = this.router.route(path);
        var args = [].slice.call(arguments, 1);
        route[method].apply(route, args);
        return this;
      }.bind(this));
    }.bind(this));
  }
767624
public function add($url, $method, $action)
	{	
		$route = $this->factory->create($url, $method, $action);

		$this->routes[] = $route;

		foreach ($route->getMethod() as $method) {
			$this->routesByMethod[$method][] = $route;
		}
	}
1126751
public function addRoute(array $methods, array $versions, $uri, $action)
    {
        $this->createRouteCollections($versions);

        foreach ($versions as $version) {
            foreach ($this->breakUriSegments($uri) as $uri) {
                $this->routes[$version]->addRoute($methods, $uri, $action);
            }
        }
    }
1154540
function call(handle, route, err, req, res, next) {
  var arity = handle.length;
  var hasError = Boolean(err);

  debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);

  try {
    if (hasError && arity === 4) {
      // error-handling middleware
      handle(err, req, res, next);
      return;
    } else if (!hasError && arity < 4) {
      // request-handling middleware
      handle(req, res, next);
      return;
    }
  } catch (e) {
    // reset the error
    err = e;
  }

  // continue
  next(err);
}
326357
function customHTTPAction( $http, $action, $parameters = array() )
    {
        $dataType = $this->dataType();
        if ( $dataType )
            $dataType->customObjectAttributeHTTPAction( $http, $action, $this, $parameters );
    }
1111462
public function addRoute(array $methods, string $route, $handler): void
    {
        if ($methods === []) {
            throw new \InvalidArgumentException('Methods is empty');
        }

        if (\is_callable($handler)) {
            $handler = \Closure::fromCallable($handler);
        } elseif (!\is_array($handler)) {
            throw new \InvalidArgumentException('Handler is not a valid type: ' . \var_export($handler, true));
        }

        $parts = \explode('/', \trim($route, static::SEPARATOR_TRIM));

        if (!isset($parts[1]) && $parts[0] === '') {
            $parts = [];
        }

        $current = &$this->routes;
        foreach ($parts as $v) {
            if ($v[0] === '{' && $v[-1] === '}') {
                $v = \substr($v, 1, -1);
                if (\strpos($v, ':') !== false) {
                    [$name, $regexp] = \explode(':', $v, 2);

                    $regexp = '/^' . $regexp . '$/';
                    if (!isset($current['regexps'][$regexp])) {
                        $current['regexps'][$regexp] = [
                            'children' => [],
                            'regexps' => [],
                            'name' => $name,
                        ];
                    }
                    $current = &$current['regexps'][$regexp];
                } else {
                    if (!isset($current['others'])) {
                        $current['others'] = [
                            'children' => [],
                            'regexps' => [],
                            'name' => $v,
                        ];
                    }
                    $current = &$current['others'];
                }
            } else {
                if (!isset($current['children'][$v])) {
                    $current['children'][$v] = [
                        'children' => [],
                        'regexps' => [],
                    ];
                }
                $current = &$current['children'][$v];
            }
        }

        $current['route'] = $route;

        if (!isset($current['methods'])) {
            $current['methods'] = [];
        }

        foreach ($methods as $v) {
            $current['methods'][\strtoupper($v)] = $handler;
        }
    }
167300
private function runView(): void
    {
        $action = ($this->routeAction) ? $this->routeAction : 'index';

        \call_user_func([$this->view, $action]);
    }
208653
public function run() {
		// Setup our default error route responders
		$this->setup_error_routes();

		// To always be RESTful, create a last-hit route responder to respond in our designated format ALWAYS
		Router::route( function( $request, $response, $service, $matches ) {
			// ALWAYS respond with our formatting function
			Router::app()->api_respond();
		});

		// Finally, call "dispatch" to have our App's Router route the request appropriately
		Router::dispatch(
			substr(
				$_SERVER['REQUEST_URI'],
				strlen( rtrim( $this->config['app-meta']['base_url'], '/' ) ) // Remove a potential trailing slash
			)
		);
	}
350363
public function setRoute(array $methods, string $regexp, $callable): RouteInterface
    {
        return $this
            ->setMethods($methods)
            ->setRegexp($regexp)
            ->setCallback($callable);
    }
256594
private function addRoute($method, $pattern, $action)
    {

        if (is_array($method)) {
            foreach ($method as $verb) {
                $this->routes[$verb . $pattern] = ['method' => $verb, 'uri' => self::patternFactory($pattern), 'action' => $action];
            }
        } else {
            $this->routes[$method . $pattern] = ['method' => $method, 'uri' => self::patternFactory($pattern), 'action' => $action];
        }
    }