passed something like (^|.*_)enclosing_resource(s)_.*(url|path)$, will
 return the [route, route_method]  for the expanded resource
514132
def route_and_method_from_enclosing_resource_method_and_name_prefix(method, name_prefix)
      if enclosing_resource
        enclosing_route = name_prefix.sub(/_$/,'')
        route_method = method.to_s.sub(/enclosing_resource(s)?/) { $1 ? enclosing_route.pluralize : enclosing_route }
        return [Rails.application.routes.named_routes.get(route_method.sub(/_(path|url)$/,'').to_sym), route_method]
      else
        raise NoMethodError, "Tried to map :#{method} but there is no enclosing_resource for this controller"
      end
    end
149959
function findRoutes (dir, fileExtensions) {
  let files = fs.readdirSync(dir)
  let resolve = f => path.join(dir, f)
  let routes = files.filter(f => fileExtensions.indexOf(path.extname(f)) !== -1).map(resolve)
  let dirs = files.filter(f => fs.statSync(path.join(dir, f)).isDirectory()).map(resolve)
  return routes.concat(...dirs.map(subdir => findRoutes(subdir, fileExtensions)))
}
398199
def get_expanded_path(self, path):
        
        if path.startswith('~'):
            return os.path.expanduser('~') + path[1:]
        else:
            return path
1034108
def get_url(path, host, port, method="http"):
    
    return urlunsplit(
        (method, "%s:%s" % (host, port), path, "", "")
    )
1337104
def allowed_extension(*allowed):
    '''
    
    '''
    def predicate(info, request):
        log.debug(request.path)
        ext = os.path.splitext(request.path)[1]
        request.environ['path_extenstion'] = ext
        log.debug(ext)
        return ext in allowed

    return predicate
954143
def get_full_path(request):
    
    path = request.path
    if request.query_string:
        path += '?' + to_native(request.query_string)
    return path
139532
def load_wildcard(as = nil)
      seg = nesting_segments[enclosing_resources.size] or ResourcesController.raise_resource_mismatch(self)

      segment = seg[:segment]
      singleton = seg[:singleton]

      if resource_specification_map[segment]
        spec = resource_specification_map[segment]
        spec = spec.dup.tap {|s| s.as = as} if as
      else
        spec = Specification.new(singleton ? segment : segment.singularize, :singleton => singleton, :as => as)
      end
      load_enclosing_resource_from_specification(spec)
    end
251381
def _GetExpandedPaths(args):
  """"""
  opts = globbing.PathOpts(
      follow_links=args.follow_links, pathtype=args.pathtype)

  for path in args.paths:
    for expanded_path in globbing.ExpandPath(str(path), opts):
      yield expanded_path
689364
function(uri) {

        if (this._routes[uri] !== undefined) {
            return uri;
        }

        for (var route in this._routes) {
            if (this.is(route, uri)) {
                return route;
            }
        }

        return false;
    }
1019494
def add_get(self, path: str, handler: _WebHandler, *,
                name: Optional[str]=None, allow_head: bool=True,
                **kwargs: Any) -> AbstractRoute:
        
        resource = self.add_resource(path, name=name)
        if allow_head:
            resource.add_route(hdrs.METH_HEAD, handler, **kwargs)
        return resource.add_route(hdrs.METH_GET, handler, **kwargs)
1067548
def for(path, *args)
      arg = args[0]
      log.debug "Adding route, path: #{path}, args: #{args.inspect}"

      match = get_regex_for_route(path, arg)
      hash = get_to_hash(arg)
      route_info = {:regex => match[:regex], :args => arg, :vars => match[:vars], :hash => hash}
      
      # Add the HTTP methods for this route if they exist in options
      route_info[:methods] = arg[:methods] if not arg.nil? and arg.has_key? :methods
      
      self.routes.push(route_info)
    end
868802
function route(method, path, handler, config) {

    if( (typeof method !== 'string' && !Array.isArray(method))
        || (typeof path !== 'string')
        || (typeof handler !== 'function' && typeof handler !== 'string' && typeof handler !== 'object')
        || (config != null && typeof config !== 'object') ) {
        throw new TypeError('Bad arguments');
    }

    if (typeof method === 'string') {
        method = method.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        if (method.match(/ /)) {
            method = method.split(' ');
        }
    }
    if (Array.isArray(method)) {
        method = method.map(function (x) {
            return x.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        });
        method.forEach(function (elem) {
            if (elem.match(/[^A-Z*]/)) {
                throw new TypeError('Bad arguments');
            }
        });
    }
    return {
        method: method,
        path: path,
        handler: handler,
        config: config
    };
}
948781
def resource(path, params={})
      r = Resource.process_detailed(self, *do_get(path, params))

      # note that process_detailed will make a best-effort to return an already
      # detailed resource or array of detailed resources but there may still be
      # legacy cases where #show is still needed. calling #show on an already
      # detailed resource is a no-op.
      r.respond_to?(:show) ? r.show : r
    end
293134
def find_matching_middleware(self, method, path):
        
        for mw in self.mw_list:
            if not mw.matches_method(method):
                continue

            # get the path matching this middleware and the 'rest' of the url
            # (i.e. the part that comes AFTER the match) to be potentially
            # matched later by a subchain
            path_match, rest_url = mw.path_split(path)
            if self.should_skip_middleware(mw, path_match, rest_url):
                continue

            yield mw, path_match, rest_url
354308
def get(self, path=None, method='GET', **options):
        
        return self.route(path, method, **options)
688764
def _get(self, url, method, host):
        
        url = unquote(host + url)
        # Check against known static routes
        route = self.routes_static.get(url)
        method_not_supported = MethodNotSupported(
            "Method {} not allowed for URL {}".format(method, url),
            method=method,
            allowed_methods=self.get_supported_methods(url),
        )
        if route:
            if route.methods and method not in route.methods:
                raise method_not_supported
            match = route.pattern.match(url)
        else:
            route_found = False
            # Move on to testing all regex routes
            for route in self.routes_dynamic[url_hash(url)]:
                match = route.pattern.match(url)
                route_found |= match is not None
                # Do early method checking
                if match and method in route.methods:
                    break
            else:
                # Lastly, check against all regex routes that cannot be hashed
                for route in self.routes_always_check:
                    match = route.pattern.match(url)
                    route_found |= match is not None
                    # Do early method checking
                    if match and method in route.methods:
                        break
                else:
                    # Route was found but the methods didn't match
                    if route_found:
                        raise method_not_supported
                    raise NotFound("Requested URL {} not found".format(url))

        kwargs = {
            p.name: p.cast(value)
            for value, p in zip(match.groups(1), route.parameters)
        }
        route_handler = route.handler
        if hasattr(route_handler, "handlers"):
            route_handler = route_handler.handlers[method]
        return route_handler, [], kwargs, route.uri
359364
def get_resources
      routes_doc = get_routes_doc
      resources_names = routes_doc.get_resources_names - resources_black_list

      resources_names.map do |resource|
        puts "Generating #{resource} documentation..." if trace?
        ResourceDoc.new( resource, routes_doc.get_actions_route_info( resource ) )
      end
    end