Define the "web" routes for the application..

@throws \Exception
170776
protected function mapRoutes()
    {
        if (!$this->app->routesAreCached()) {
            Route::group(
                ['middleware' => ['web']], function () {
                    $routes = new Routes();

                    // Backend Routes
                    $routes->mapBackendRoutes()
                        ->mapPluginsBackendRoutes();

                    // Frontend Routes
                    $routes->mapFrontendBaseRoutes()
                        ->mapFrontendRoutes()
                        ->mapThemeRoutes()
                        ->mapPluginsFrontendRoutes();

                    // Add Language {lang} prefix
                    $routes->addLanguagePrefix()
                        ->sortRoutes();
                }
            );
        }
    }
116430
public static function load() {
        $configFile = MODULES_DIR . DS . RouteController::$currentModule . '/Config/config.php';

        if (!file_exists($configFile)) {
            $configFile = BASE_DIR . '/config/config.php';
            if (!file_exists($configFile)) {
                throw new \Exception(ExceptionMessages::CONFIG_FILE_NOT_FOUND);
            }
        }

        if (empty(self::$configs)) {
            self::$configs = require_once $configFile;
        }
    }
566489
public function map() {
		$modules = Module::all();
		
		//dd($modules);
		
		foreach ($modules as $module) {
			$routes = $module->routes;
			$routesFolder = 'routes'.DIRECTORY_SEPARATOR;
			
			if ($routes) {
				foreach ($routes as $route) {
					if (strrpos($route, $routesFolder."web")) {
						
						$this->mapWebRoute($route, $module->namespace);
					}
					elseif (strrpos($route, $routesFolder."api")) {
						
						$this->mapApiRoute($route, $module->namespace);
					}
				}
			}
		}
	}
1148602
public function launch()
	{
		// Was the application route defined?
		if ($this->_app_root === null) {
			throw new FemtoException('You must define the application route first, do so by calling $femto->setAppRoot($dir)');
		}

		try {
			// Load the page, if one isn't specified in the request load the index page
			$this->_request_uri = str_replace(array('?', $_SERVER['QUERY_STRING']), '', $_SERVER['REQUEST_URI']);
			$this->_loadPage(trim($this->_request_uri === '/' ? 'index' : $this->_request_uri, '/'));
		} catch (FemtoPageNotFoundException $e) {
			// Set a 404 header because we couldn't find the page
			header('HTTP/1.1 404 Not Found');

			// We need to reset the template state
			$this->_resetTemplate();

			// Make sure the 404 is maintained if the 404 page doesn't exist
			try {
				$this->_loadPage('404');
			} catch (Exception $e) {}
		} catch (Exception $e) {
			// Discard the output buffer, we don't want to display content
			// if an exception was caught
			ob_end_clean();

			// Let the world know that you messed up
			header('HTTP/1.1 500 Internal Server Error');

			// We need to reset the template state
			$this->_resetTemplate();

			// Load the 500 page, if this fails it doesn't really make any difference
			$this->_loadPage('500', array('e' => $e));
		}
	}
448594
public static function route(): AbstractRoute
    {
        if (static::$routing === null) {
            $config = static::getConfig('application');
            $routingClassName = $config->get('routing_class');
            $routeOptions = $config->get('routing_options') ?? [];

            if ($routingClassName == null) {
                static::terminateWithError('Can not init routing class when routing_class is not set in application config');
            }

            static::$routing = new $routingClassName($routeOptions);
        }

        return static::$routing;
    }
634657
protected function addAppRoutes()
    {
        $routes = $this->getConfig('routes');
        if (is_array($routes)) {
            $this->getRouter()->addRoutes($routes);
        }
    }
993620
public function boot()
    {
        if ($this->app->getProps() === null) {
            return;
        }

        $routes = [];
        $pathPrefix = $this->app->getProp($this->routesPathPrefixPropName, '');
        $propRoutes = $this->app->getProp($this->routesPropName, []);

        if (!is_array($propRoutes)) {
            throw new \Exception('Routes definitions must be an array!');
        }

        foreach ($this->app->getProp($this->routesPropName, []) as $route) {
            $this->validate($route);
            $routes[] = $this->app->createRoute(
                $route['method'] ?? null,
                $pathPrefix.$route['path'],
                $route['stack']
            );
        }

        $this->app->stack($routes);
    }
326038
protected function loadRoutes()
    {
        if (($routes = $this->app['config']['http.routes']) == null) {
            return;
        }

        $router = $this->app['router'];

        $namespace = $this->getNamespace();

        foreach ($routes as $route) {
            if ($route instanceof Closure) {
                // We can defined routes with a Closure.
                call_user_func($route, $router);

                continue;
            }

            $attributes = $this->normalizeRouteAttributes($route);

            $filePath = array_pull($attributes, 'path');

            if ($namespace) {
                $attributes['namespace'] = $this->getGroupRouteNamespace($namespace, $attributes);
            }

            if (file_exists($filePath)) {
                $router->group($attributes, function ($router) use ($filePath) {
                    include $filePath;
                });
            }
        }
    }
906609
protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => ['soda.web'],
            'namespace'  => $this->namespace,
        ], function ($router) {
            require __DIR__.'/../../routes/web.php';
        });

        $this->app['router']->getRoutes()->refreshNameLookups();

        $this->app['events']->fire('soda.routing', $this->app->router);
    }
81992
protected function mapWebRoutes()
    {
        if (request()->segment(1) == 'api' || request()->segment(2) == 'api') {
            return;
        }
        
        Route::group([
            'middleware' => 'web',
            'namespace'  => $this->namespace,
            'prefix'     => trans_setlocale(),
        ], function ($router) {
            require (__DIR__ . '/../../routes/web.php');
        });
    }
939735
private function route() : void
    {
        // Parse route
        $parsed = $this->parseRoute();

        // Run error controller when no route matched
        if (!$parsed && isset($this->error_controller)) {
            call_user_func($this->error_controller);
        }
    }
999268
private function parsePath()
    {
        $components = array();
        $uri = $this->getUri();

        if ($uri !== false) {
            Logger::get()->debug('Parsing URI: ' . $uri);
            // Add the URL parameters.
            $components = $this->getHttpParameters();

            $matched = false;
            foreach (self::getRoutes() as $route) {
                if (preg_match("#^{$route['uri']}$#", $uri, $matches)) {
                    Logger::get()->debug('Found a matching route: ' . $route['uri']);
                    foreach ($route as $name => $value) {
                        switch ($name) {
                            case 'uri':
                                // Ignore.
                                break;
                            default:
                                if (is_numeric($value)) {
                                    // If the value is a number, it refers to a
                                    // regex block in the route.
                                    if (isset($matches[$value])) {
                                        $components[$name] = $matches[$value];
                                    }
                                } else {
                                    // Otherwise it's the parameter's value.
                                    $components[$name] = $value;
                                }
                                break;
                        }
                    }

                    $matched = true;
                    break;
                }
            }

            // If no matching routes have been found, the request is not
            // considered valid.
            if (!$matched) {
                throw new Exception("No routes match URI '{$uri}'.", 404);
            }
        }

        return $components;
    }
632570
public function run(HTTPRequest $request) {
		$options = $request->getRoute()->getOptions();
		if( !empty($options['url_config']) ) {
			$url = AppConfig::instance()->get($options['url_config']);
			if( !$url ) {
				throw new Exception('The RedirectController requires a valid url_config option, please check your configuration.');
			}
		} else
		if( empty($options['redirect']) ) {
			throw new Exception('The RedirectController requires a redirect option, add it to your route configuration.');
		} else {
			$url = u($options['redirect']);
		}
		return new RedirectHTTPResponse($url);
	}
968928
public function map()
    {
        $appPath = __DIR__ . DIRECTORY_SEPARATOR;
        $path = $appPath . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "routes" . DIRECTORY_SEPARATOR;

        $this->mapApiRoutes($path);

        $this->mapWebRoutes($path);

        //
    }
1350141
public function route()
	{
		$content = $this->_controller->{$this->_actionMethod}();

		if ($this->_controller->isJson()) {
			Request::setHeader(Request::HEADER_JSON);
			echo json_encode($content);
		} else {
			echo $content;
		}
	}
1328534
protected function run()
    {
        // First convert via subrouting defined routes to a parsable array tree
        $this->setRouteTree(explodeTree($this->getRoutes(), self::ROUTE_SEPARATOR));

        // Retrieve route configuration via match by current request URL ;)
        $routeConfig = $this->getRouteByUrl($this->getStateObject()->getUrl());

        // Real processed request method depends on the override header if set. Otherwise normal request type is used
        $headers = $this->getStateObject()->getHeaders();

        // Override set? and is allowed for the resource? Sometimes clients are not able to e.g. tunnel PUT, DELETE ...
        if (isset($headers['X_HTTP_METHOD_OVERRIDE']) === true && $routeConfig->getOverride() === true) {
            $requestMethod = $headers['X_HTTP_METHOD_OVERRIDE'];

            // Inject into object we use as base -> update :)
            $this->getStateObject()->setMethod($requestMethod);
        } else {
            $requestMethod = $this->getStateObject()->getMethod();
        }

        // Request method should not be processed.
        if ($routeConfig->isAllowed($requestMethod) === false) {
            throw new Doozr_Base_Presenter_Rest_Exception(
                'Method "'.$this->getStateObject()->getMethod().'" not allowed.',
                405
            );
        }

        // Missing argument + message
        if ($this->validateInputArguments(
                $routeConfig->getRequired(),
                $this->getStateObject()->getQueryParams()
            ) !== true
        ) {
            $missingArguments = [];

            foreach ($routeConfig->getRequired() as $key => $value) {
                if (array_key_exists($key, $this->getStateObject()->getQueryParams()->getArray()) === false) {
                    $missingArguments[] = $key.(($value !== null) ? ' => '.$value : '');
                }
            }

            throw new Doozr_Base_Presenter_Rest_Exception(
                'Missing required argument'.((count($missingArguments) > 1) ? 's' : '').': '.
                implode(',', $missingArguments),
                406
            );
        }

        // Try to get data and check if authorization required and failed
        $data = $this->getModel()->getData(
            $this->getStateObject(), $routeConfig
        );

        // Retrieve data from model so that VIEW and MODEL are informed (Observer and this here is the Subject)
        $this->setData(
            $data
        );
    }
116616
public function route(Request $request)
    {
        if ($request instanceof Request\Web) {
            $server = $request->getServer();
            if (!isset($server['REQUEST_URI'])) {
                throw new Exception('REQUEST_URI is not set');
            }
            $this->logger->debug('Routing of web request', ['REQUEST_URI' => $server['REQUEST_URI']]);
            $urlComponents = explode('?', $server['REQUEST_URI']);
            $destination = reset($urlComponents);
            if (strpos($destination, $this->entryPoint) === 0) {
                $destination = substr($destination, strlen($server['SCRIPT_NAME']));
            }
        } elseif ($request instanceof Request\Cli) {
            $argv = $request->getArgv();
            $destination = isset($argv[1]) ? $argv[1] : '/';
            $this->logger->debug('Routing of CLI request', ['argv' => $argv]);
        } elseif ($request instanceof Request\Virtual) {
            $this->logger->debug(
                'Routing of virtual request',
                ['controller' => $request->getController(), 'action' => $request->getAction()]
            );
            return new Route($request->getController(), $request->getAction());
        } else {
            throw new Exception('Request type not supported');
        }

        $destination = trim($destination, '/');
        $destination = empty($destination) ? '/' : $destination;

        $this->logger->debug('Searching for corresponding route', ['destination' => $destination]);

        return $this->getRoute($destination);
    }