/*
private service that holds route mappings for each controller
499238
function $controllerIntrospectorProvider() {
  var controllers = [];
  var controllersByName = {};
  var onControllerRegistered = null;
  return {
    register: function (name, constructor) {
      if (angular.isArray(constructor)) {
        constructor = constructor[constructor.length - 1];
      }
      controllersByName[name] = constructor;
      if (constructor.$routeConfig) {
        if (onControllerRegistered) {
          onControllerRegistered(name, constructor.$routeConfig);
        } else {
          controllers.push({name: name, config: constructor.$routeConfig});
        }
      }
    },
    $get: ['$componentMapper', function ($componentMapper) {
      var fn = function (newOnControllerRegistered) {
        onControllerRegistered = function (name, constructor) {
          name = $componentMapper.component(name);
          return newOnControllerRegistered(name, constructor);
        };
        while(controllers.length > 0) {
          var rule = controllers.pop();
          onControllerRegistered(rule.name, rule.config);
        }
      };

      fn.getTypeByName = function (name) {
        return controllersByName[name];
      };

      return fn;
    }]
  }
}
200854
function(callback) {
            async.map(modules, function(module, callback) {
                callback && callback(
                    null,
                    {
                        name: module,
                        path: process.cwd() + '/modules/' +
                              module + '/controllers/'
                    }
                );
            }, callback);
        }
705681
function initRoutes (config, route) {
    // create express router for route
    route.router = express.Router({
        caseSensitive: true,
        strict: true,
    })
    // initialize routes depth first so that explicit nested paths come
    // before wildcard paths and are handled correctly by express router
    _.each(route.routes, (subRoute, path) => {
        // get router for sub route
        var router = initRoutes(config, subRoute)
        // bind route for path
        route.router.use('/'+path+'/', router)
    })
    // clear model if no properties are set
    if (_.keys(route.model).length === 0) {
        route.model = undefined
    }
    // clear controller if no properties are set
    if (_.keys(route.controller).length === 0) {
        route.controller = undefined
    }
    // instantiate ImmutableCoreModel
    if (defined(route.model)) {
        route.model = new ImmutableCoreModel(route.model)
        // add model to app register
        config.models[route.model.name] = route.model
    }
    // if model is not set use model for this node
    if (defined(route.controller) && !defined(route.controller.model)) {
        route.controller.model = route.model
    }
    // instantiate ImmutableCoreController - this will create default controllers
    // for model
    var controller = route.controller = new ImmutableCoreController(route.controller)
    // get all templates then remove those that have controllers
    var bareTemplates = _.cloneDeep(route.templates)
    // iterate over paths
    _.each(controller.paths, path => {
        // iterate over http methods for path
        _.each(path, methods => {
            // iterate over handlers for different roles
            _.each(methods, spec => {
                // role can be specific or default to all
                var role = spec.role || 'all'
                // template can be specified or take from method name
                var template = spec.template || spec.methodName
                // template name exists locally
                if (defined(route.templates[template])) {
                    // if there is a template for the controllers role then remove
                    // it from the list of unused templates
                    if (defined(bareTemplates[template].role[role])) {
                        delete bareTemplates[template].role[role]
                    }
                    // otherwise if there is a template for all roles then assign
                    // it to this controller so that another controller for the
                    // all role will not be created to serve the template
                    else if (defined(bareTemplates[template].role['all'])) {
                        delete bareTemplates[template].role['all']
                    }
                }
            })
        })
    })
    // set to true if any controllers addded
    var added = false
    // create paths for any templates without controllers
    _.each(bareTemplates, (template, templateName) => {
        // iterate over any templates for roles that have not been used
        _.each(template.role, (templatePath, role) => {
            // get path from template name with index becoming /
            var path = templateName === 'index' ? '/' : '/'+templateName
            // create entry for path in controller if not yet defined
            if (!controller.paths[path]) {
                controller.paths[path] = {}
            }
            // create entry for method if not yet defined
            if (!controller.paths[path]['get']) {
                controller.paths[path]['get'] = []
            }
            // add spec for template to controller
            controller.paths[path]['get'].push({
                role: role,
                template: templatePath,
            })
        })
    })
    // if controllers were added then need to reorder controllers
    if (added) {
        controller.orderControllers()
    }
    // get list of path names
    var pathNames = _.keys(controller.paths)
    // sort path names so that static names go above onces with placeholders
    var sortedPathNames = pathNames.sort(sortPlaceholdersLower)
    // create routes for controller paths
    _.each(sortedPathNames, path => {
        var methods = controller.paths[path]
        // add route for each method
        _.each(methods, (spec, method) => {
            // create ImmutableAppPresenter instance
            var presenter = new ImmutableAppPresenter({
                config: config,
                method: method,
                module: module,
                path: path,
                route: route,
                spec: spec,
            })
            // middleware for route
            var routeMiddleware = []
            // iterate over spec(s) for different roles
            _.each(spec, roleSpec => {
                // if spec has middleware add to router
                _.each(roleSpec.middleware, middleware => {
                    routeMiddleware.push(middleware)
                })
            })
            // add presenter as final middleware
            routeMiddleware.push(presenter)
            // add path to router with method
            route.router[method](path, routeMiddleware)
        })
    })
    // return router so it can be bound to parent
    return route.router
}
796518
function getRoute(route) {
                for (var key in settings.routes) {
                    if (key === route) {
                        return settings.routes[key];
                    }
                }
            }
585878
function () {
    var routes = Array.prototype.slice.call(arguments);
    if (routes.length) {
      Ember.A(routes).forEach(function (child) {
        this._route(child);
      }, this);
    }
    else {
      if (!this.get('isResource')) {
        this.set('isResource', true);
      }
    }
    return this;
  }
1365701
function bind(method, path, controller, action) {
    let handler = controllerRegistry[controller] && controllerRegistry[controller][action]
    if (!handler) {
      console.warn(`can't bind route ${ path } to unknown action ${ controller }.${ action }`)
      return
    }

    const policyName = LocalUtil.getPolicyName(policy, controller, action)
    let currentPolicy
    if (policyName) currentPolicy = policyRegistry[policyName]

    if (currentPolicy) {
      router[method](path, currentPolicy, handler)
    } else {
      router[method](path, handler)
    }
  }
896596
public function map()
    {
        Route::namespace($this->namespace)->group(function (Router $router) {
            /*
             * Admin routes
             */
            $router->middleware('admin')->prefix('admin')->group(function (Router $router) {
                $router->get('menus', 'AdminController@index')->name('admin::index-menus')->middleware('can:see-all-menus');
                $router->get('menus/create', 'AdminController@create')->name('admin::create-menu')->middleware('can:create-menu');
                $router->get('menus/{menu}/edit', 'AdminController@edit')->name('admin::edit-menu')->middleware('can:update-menu');
                $router->post('menus', 'AdminController@store')->name('admin::store-menu')->middleware('can:create-menu');
                $router->put('menus/{menu}', 'AdminController@update')->name('admin::update-menu')->middleware('can:update-menu');

                $router->get('menus/{menu}/menulinks/create', 'MenulinksAdminController@create')->name('admin::create-menulink')->middleware('can:create-menu');
                $router->get('menus/{menu}/menulinks/{menulink}/edit', 'MenulinksAdminController@edit')->name('admin::edit-menulink')->middleware('can:update-menu');
                $router->post('menus/{menu}/menulinks', 'MenulinksAdminController@store')->name('admin::store-menulink')->middleware('can:create-menu');
                $router->put('menus/{menu}/menulinks/{menulink}', 'MenulinksAdminController@update')->name('admin::update-menulink')->middleware('can:update-menu');
            });

            /*
             * API routes
             */
            $router->middleware('api')->prefix('api')->group(function (Router $router) {
                $router->middleware('auth:api')->group(function (Router $router) {
                    $router->get('menus', 'ApiController@index')->middleware('can:see-all-menus');
                    $router->patch('menus/{menu}', 'ApiController@updatePartial')->middleware('can:update-menu');
                    $router->delete('menus/{menu}', 'ApiController@destroy')->middleware('can:delete-menu');

                    $router->get('menus/{menu}/menulinks', 'MenulinksApiController@index')->middleware('can:see-all-menus');
                    $router->patch('menus/{menu}/menulinks/{menulink}', 'MenulinksApiController@updatePartial')->middleware('can:update-menu');
                    $router->post('menus/{menu}/menulinks/sort', 'MenulinksApiController@sort')->middleware('can:update-menu');
                    $router->delete('menus/{menu}/menulinks/{menulink}', 'MenulinksApiController@destroy')->middleware('can:delete-menu');
                });
            });
        });
    }
1333443
protected function mapWebRoutes()
    {
        $namespace = 'CoasterCms\Http\Controllers';
        $routeName = 'coaster.';
        $routesDir = realpath(__DIR__ . '/../routes/web');
        $adminRouteName = $routeName . 'admin.';
        $adminUrl = config('coaster::admin.url') . '/';

        if (!Install::isComplete()) {
            Route::middleware(['web'])
                ->as($routeName . 'install.')
                ->namespace($namespace)
                ->group($routesDir . '/install.php');
        }

        if (\App::runningInConsole() || \Request::segment(1) == rtrim($adminUrl, '/') || config('coaster::admin.always_load_routes')) {
            Route::middleware(['web', 'coaster.admin'])
                ->prefix($adminUrl)
                ->as($adminRouteName)
                ->namespace($namespace . '\AdminControllers')
                ->group($routesDir . '/admin-auth.php');
        }

        Route::middleware(['web', 'coaster.guest'])
            ->prefix($adminUrl)
            ->as($adminRouteName)
            ->namespace($namespace . '\AdminControllers')
            ->group($routesDir . '/admin-guest.php');

        Route::middleware(['web', 'coaster.admin'])
            ->prefix($adminUrl)
            ->as(rtrim($adminRouteName, '.'))
            ->namespace($namespace)
            ->group($routesDir . '/admin.php');

        Route::middleware(['web'])
            ->namespace($namespace)
            ->group($routesDir . '/cms.php');
    }
1195442
public static void mapping() {
        for (final Router router : routers) {
            final ContextHandlerMeta contextHandlerMeta = router.toContextHandlerMeta();
            RouteHandler.addContextHandlerMeta(contextHandlerMeta);
        }
    }
989709
function Route(config) {
    return function (target, propertyKey, descriptor) {
        target.addRouteConfig({
            endpoint: config != null ? config.endpoint : null,
            method: config != null ? config.method : null,
            routeFunction: descriptor.value,
            useAuth: config != null ? config.useAuth : false,
            middlewares: config != null ? config.middlewares : null
        });
    };
}
1340302
protected function mapWebRoutes() {

		include_once base_path('routes/configurations.php');

		Route::middleware(['web'])
			->namespace($this->namespace)
			->group(base_path('routes/admin.php'));

		Route::middleware(['web'])
			->namespace($this->namespace)
			->group(base_path('routes/web.php'));

	}
493837
public function load($resource, $type = null): RouteCollection
    {
        $resource = (string)$resource;
        if (in_array($resource, $this->descriptions)) {
            throw new \RuntimeException("Resource '$resource' was already loaded");
        }

        $description = $this->repository->get($resource);

        $routes           = new RouteCollection();
        $router           = $description->getExtension('router') ?: "$this->typeName.controller";
        $routerController = $description->getExtension('router-controller');

        foreach ($description->getPaths() as $pathItem) {
            $relativePath = ltrim($pathItem->getPath(), '/');
            $resourceName = strpos($relativePath, '/')
                ? substr($relativePath, 0, strpos($relativePath, '/'))
                : $relativePath;

            $routerController = $pathItem->getExtension('router-controller') ?: $routerController;

            foreach ($pathItem->getOperations() as $operation) {
                $controllerKey = $this->resolveControllerKey(
                    $operation,
                    $resourceName,
                    $router,
                    $routerController
                );
                $defaults      = [
                    '_controller'               => $controllerKey,
                    RequestMeta::ATTRIBUTE_URI  => $resource,
                    RequestMeta::ATTRIBUTE_PATH => $pathItem->getPath(),
                ];

                $route = new Route(
                    $pathItem->getPath(),
                    $defaults,
                    $this->resolveRequirements($operation),
                    [],
                    '',
                    $description->getSchemes()
                );
                $route->setMethods($operation->getMethod());
                $routes->add($this->createRouteId($resource, $pathItem->getPath(), $controllerKey), $route);
            }
        }

        $this->descriptions[] = $resource;

        return $routes;
    }
722773
def map ref,route, options={}
      context = Context.collection[get_context]
      context.routes[ref]= Route.new(route, context,options)
    end
1066918
private Map<Method, Class<? extends Annotation>> getControllerMethods(Class<? extends Controller> controllerClass) {
        // collect the annotated methods
        Map<Method, Class<? extends Annotation>> controllerMethods = new LinkedHashMap<>();

        // discover all annotated controllers methods
        for (Method method : ClassUtils.getDeclaredMethods(controllerClass)) {
            for (Annotation annotation : method.getAnnotations()) {
                Class<? extends Annotation> annotationClass = annotation.annotationType();
                if (httpMethodAnnotationClasses.contains(annotationClass)) {
                    controllerMethods.put(method, annotationClass);
                    break;
                }
            }
        }

        return controllerMethods;
    }
504754
function route() {
        configure()

        middlewares()

        for (let route of config.routes) {
            if (route.type === 'view')
                server[route.method](route.src, (req, res) => {
                    res.render(`${app.root}/views/${route.dest}.twig`, {})
                })

            if (route.type === 'controller') {
                let [path, method] = route.dest.split('::')

                let controller = function () {
                    if (!app.controllers)
                        return require(`${app.root}/controllers/${path.replace('.', '/')}`)(app)

                    if (path.split('.').length > 1)
                        return app.controllers[path.split('.')[0]][path.split('.')[1]]
                    else
                        return app.controllers[path]
                }()

                let func = wrapper(controller[method])
                if (!func)
                    app.drivers.logger.error('blockbase-express - wrapper', `Undefined function ${controller}${method}`)

                if (route.method === 'post' || route.method === 'put')
                    server[route.method](route.src, upload.any(), func)
                else
                    server[route.method](route.src, func)
            }
        }

        errors()
    }
506165
public void bind(T service, Map<String, Object> props) {
    synchronized (serviceMap) {
      serviceMap.put(ServiceUtil.getComparableForServiceRanking(props), service);
      updateSortedServices();
    }
  }
1172546
function logRoute(routeConfig, filters) {
        filters = filters ? filters.join(', ') : "";
        $log.info(
            '{method="%s", path="%s", filters="%s"} bind on controller %s#%s',
            routeConfig.method,
            routeConfig.path,
            filters,
            routeConfig.controller,
            routeConfig.action
        );
    }