Route resource to single controller
341416
public static function resource(){
        $arguments  = func_get_args();
        $path       = $arguments[0];
        $controller = end($arguments);

        $resourceRoutes = array(
            'get'           => array(
                'pattern'       => "$path",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_paginate'  => array(
                'pattern'       => "$path/page/:page",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_create'    => array(
                'pattern'       => "$path/create",
                'method'        => 'get',
                'handler'       => "$controller:create"
            ),
            'get_edit'      => array(
                'pattern'       => "$path/:id/edit",
                'method'        => 'get',
                'handler'       => "$controller:edit"
            ),
            'get_show'      => array(
                'pattern'       => "$path/:id",
                'method'        => 'get',
                'handler'       => "$controller:show"
            ),
            'post'          => array(
                'pattern'       => "$path",
                'method'        => 'post',
                'handler'       => "$controller:store"
            ),
            'put'           => array(
                'pattern'       => "$path/:id",
                'method'        => 'put',
                'handler'       => "$controller:update"
            ),
            'delete'        => array(
                'pattern'       => "$path/:id",
                'method'        => 'delete',
                'handler'       => "$controller:destroy"
            )
        );

        foreach ($resourceRoutes as $route) {
            $callable   = $arguments;

            //put edited pattern to the top stack
            array_shift($callable);
            array_unshift($callable, $route['pattern']);

            //put edited controller to the bottom stack
            array_pop($callable);
            array_push($callable, $route['handler']);

            call_user_func_array(array(self::$slim, $route['method']), $callable);
        }
    }
496963
def controller
      unless params[:controller]
        raise ControllerExceptions::NotFound,
          "Route matched, but route did not specify a controller.\n" +
          "Did you forgot to add :controller => \"people\" or :controller " +
          "segment to route definition?\nHere is what's specified:\n" +
          route.inspect
      end
      path = [params[:namespace], params[:controller]].compact.join(Merb::Const::SLASH)
      controller = path.snake_case.to_const_string

      begin
        Object.full_const_get(controller)
      rescue NameError => e
        msg = "Controller class not found for controller `#{path}'"
        Merb.logger.warn!(msg)
        raise ControllerExceptions::NotFound, msg
      end
    end
726301
public function makeForceDomainUrl ($host_name, $controller_name, $action_name = '', $parameters = [], $var_parameters = [], $query = []) {
		if ($controller_name === null) {
			return '';
		}
		$url = Router::GetUrl($controller_name, $action_name, $parameters, $var_parameters);
		$connection = Router::Find($url);
		$options = isset($connection['options']) ? $connection['options'] : [];
		$protocol = isset($options['protocol']) ? $options['protocol'] : Router::GetCurrentProtocol();

		if (preg_match("@^https?://@", $host_name) === false) {
			if (is_array($protocol)) {
				$schema = count($protocol) > 1 ? '//' : $protocol[0] . '://';
			} else {
				$schema = $protocol . '://';
			}
		} else {
			$schema = '';
		}

		$query = !empty($query) ? '?'. http_build_query($query) : '';

		return sprintf('%s%s%s%s', $schema, $host_name, $this->asset($url), $query);
	}
211235
def _route(self, action, method):
        

        # First thing, determine the path for the method
        path = method._wsgi_path
        methods = None
        if path is None:
            map_rule = self.wsgi_method_map.get(method.__name__)
            if map_rule is None:
                # Can't connect this method
                LOG.warning("No path specified for action method %s() of "
                            "resource %s" % (method.__name__, self.wsgi_name))
                return

            # Compute the path and the method list
            path = utils.norm_path(map_rule[0] % self.wsgi_name)
            methods = map_rule[1]

        # Compute route name
        name = '%s_%s' % (self.wsgi_name, action)

        # Set up path
        path = getattr(self, 'wsgi_path_prefix', '') + path

        # Build up the conditions
        conditions = {}
        if hasattr(method, '_wsgi_methods'):
            conditions['method'] = methods if methods else method._wsgi_methods
        if hasattr(method, '_wsgi_condition'):
            conditions['function'] = method._wsgi_condition

        # Create the route
        self.wsgi_mapper.connect(name, path,
                                 controller=self,
                                 action=action,
                                 conditions=conditions,
                                 **getattr(method, '_wsgi_keywords', {}))
99712
function queryController(requestUri) {
    try {
        if (requestUri === undefined)
            return null;
        //split path
        var segments = requestUri.pathname.split('/');
        //put an exception for root controller
        //maybe this is unnecessary exception but we need to search for root controller e.g. /index.html, /about.html
        if (segments.length === 2)
            return 'root';
        else
        //e.g /pages/about where segments are ['','pages','about']
        //and the controller of course is always the second segment.
            return segments[1];
    }
    catch (err) {
        throw err;
    }
}
1123365
def routing(routes, request):
    """"""

    # strip trailing slashes from request path
    path = request.path.strip('/')

    # iterate through routes to match
    args = {}
    for name, route in routes.items():
        if route['path'] == '^':
            # this section exists because regex doesn't work for null character as desired
            if path == '':
                match = [True]
            else:
                match = []
        else:
            match = re.findall(route['path'], path)
        
        if match:
            # found the matching url, iterate through variables to pass data
            # check if method exists
            if not request.method in route['method']:
                raise TornMethodNotAllowed
            
            values = match[0] # in form of tuples
            if type(values) != bool:
                for i in range(len(route['variables'])):
                    # if value is blank, check if default exists and pass it instead
                    if type(values) == str:
                        args[route['variables'][i]] = values
                    else:
                        if not values[i] and route['variables'][i] in route['defaults']:
                            values[i] = route['defaults'][route['variables'][i]]
                        args[route['variables'][i]] = values[i]
            
            # we have the variables we need, args, path, controller
            return {
                'kwargs'        : args,
                'controller'    : route['controller']
            }
    raise TornNotFoundError
985325
public void selectResource(String resourcePath, CmsUUID structureId, String title, String resourceType) {

        m_controller.selectResource(resourcePath, structureId, title, resourceType);
    }
1018537
function(req, res, next) {

        /**
         * If you want to redirect to another controller, uncomment
         */

        var controllers = [];

        fs.readdir(__dirname + '/', function(err, files) {

            if (err) {
                throw err;
            }
            files.forEach(function(file) {
                if(/\.js$/i.test(file)) {
                   if (file !== "AppsController.js") {
                       controllers.push(file.replace('Controller.js', '').toLowerCase());
                   }
                }
            });

            res.render('app', {
                controllers: controllers
            });

        });
    }
440378
private function createRouteId(string $resource, string $path, string $controllerKey): string
    {
        $controllerSegments = explode(':', $controllerKey);

        $operationName = 'action';
        if (count($controllerSegments) === 2) {
            list(, $operationName) = $controllerSegments;
        }

        $fileName       = pathinfo($resource, PATHINFO_FILENAME);
        $normalizedPath = strtolower(trim(preg_replace('/\W+/', '.', $path), '.'));
        $routeName      = "$this->typeName.{$fileName}.$normalizedPath.$operationName";

        return $routeName;
    }
114674
private function getRoute()
    {
        $route = $this->route;
        $first = substr($route, 0, 1);
        $last = substr($route, -1);
        if($first == "/") {
            $route = substr($route, 1);
        }
        if($last == "/") {
            $route = substr($route, 0, -1);
        }
        $this->resource = $route;
        
    }
851057
protected function createResourceController()
    {
        Artisan::call('make:controller', [
            'name' => $controller = $this->controllerWithoutMethod($this->action()),
            '--resource' => true
        ]);
        $this->info('Resource Controller ' . $controller .' created.');
        $this->createView($this->argument('link'));
    }
1296258
def url_for(self, resource, **values):
        """"""
        endpoint = resource.endpoint
        if self.blueprint:
            endpoint = '{0}.{1}'.format(self.blueprint.name, endpoint)
        return url_for(endpoint, **values)
1305157
function(req, res, next) {
			req.controller = controllerName;
			req.action = actionName || 'index';
			next();
		}
249011
function generateGenericControllers(controllers, models) {
        var genericControllers = {},
            genericRoute = [];

        models.forEach(function(model) {
            var persistence = $database.getPersistenceOfModel(model);
            if (null == persistence) {
                throw new Error('');
            }
            var defaultController = {};
            var modelRest = model + "Rest";

            if (controllers.hasOwnProperty(modelRest)) {
                defaultController = controllers[modelRest];
            } else if (controllers.hasOwnProperty(utils.camelizePath(modelRest))) {
                defaultController = controllers[utils.camelizePath(modelRest)];
            }

            var generatorController = persistence.generatorController;

            genericControllers[modelRest] = _.defaults({}, defaultController, generatorController.generate(persistence.repositories[model], true));
            //create
            genericRoute.push({
                method: 'post',
                controller: modelRest,
                action: 'create',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'createQuery',
                path: '/' + model + '/create'
            });

            //Read
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'index',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'findById',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'find',
                path: '/' + model + '/find'
            });

            //update
            genericRoute.push({
                method: 'put',
                controller: modelRest,
                action: 'update',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'updateQuery',
                path: '/' + model + '/update/:id'
            });

            //update
            genericRoute.push({
                method: 'delete',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/delete/:id'
            });

        });

        return [genericControllers, genericRoute]
    }
683426
function() {
      // Used for de-duping
      var paths = {};

      // Each controller has a `routes` object
      // Connect all routes defined in controllers
      _.forEach(router.controllers, function(controller) {
        _.forEach(controller.routes, function(route, method) {
          _.forEach(route, function(routeOptions, path) {
            // If path/method has already been defined, skip
            if (paths[path] === method) {
              debug.warn('Skipping duplicate route: [%s] %s', method, path);
              return;
            }

            // If no route action is defined, skip
            if (!routeOptions.action) {
              debug.warn('No action defined for route: [%s] %s', method, path);
              return;
            }

            // Setup controller scoped middleware
            // These apply to all routes in the controller
            var pre = _.invokeMap(controller.pre, 'bind', controller) || [];
            var before = _.invokeMap(controller.before, 'bind', controller) || [];
            var after = _.invokeMap(controller.after, 'bind', controller) || [];

            // Setup route scoped middleware
            // These apply only to this route
            var middleware = routeOptions.middleware || [];

            // Build the route handler (callback)
            var handler = router._buildHandler(controller, routeOptions);

            // Connect the route
            router[method](path, pre, middleware, before, handler, after);

            // Add route to set of connected routes
            router.routes.push({
              url: router.url,
              method: method,
              path: path
            });

            // Use for de-duping
            paths[path] = method;
          });
        });
      });

      // Debug logging
      _.forEach(router.routes, function(route) {
        debug.info('Route [%s] %s', route.method, route.url + route.path);
      });
    }
69139
def auto_link_paths
      paths = (controller_name / action_name).split('/')
      first = paths.shift
      paths.inject( [first] ) do |memo, val|
        memo.push [memo.last, val].join('/')
      end
    end
1225855
public function load($resource, $type = null)
    {
        $collection = new SymfonyRouteCollection();
        try{
            $results = $this->manager->findAllAlias();
        }catch (\Exception $e){
            return $collection;
        }
        foreach ($results as $metatag) {
            if (is_array($metatag['pathinfo'])) {
                $pathinfo = $metatag['pathinfo'];
            } else {
                $pathinfo = @unserialize($metatag['pathinfo']);
            }
            if (!is_array($pathinfo) || !isset($pathinfo['_route']) || !isset($metatag['alias'])) {
                continue;
            }
            $oldroute = $pathinfo['_route'];

            //add defaults to routealias
            if (isset($pathinfo['__defaults']) && is_array($pathinfo['__defaults'])) {
                foreach ($pathinfo['__defaults'] as $key => $value) {
                    if (strpos($key, '_') !== 0) {
                        $metatag['alias'] .= '-{'.$key.'}';
                    }
                }
            }
            $route = new Route($metatag['alias'], $pathinfo, array(), array());
            $collection->add(self::getRouteName($oldroute, $pathinfo), $route);
        }

        return $collection;
    }