Define webservice routes
436732
function defineRoutes (server, opts) {
    require('../route')(server, opts);
    require('../route/things')(server, opts);
    require('../route/random')(server, opts);
    require('../route/bomb')(server, opts);
    require('../route/count')(server, opts);
}
936326
public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
		String version = "1.0";
		// Get Correct API Class from Mapper
		Class<?> respCls = facade1_0.mapper().getClass(api); 
		if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
		// setup Application API HTML ContentTypes for JSON and Route
		String application = applicationJSON(respCls, version);
		route(env,meth,path,code,application,"application/json;version="+version,"*/*");

		// setup Application API HTML ContentTypes for XML and Route
		application = applicationXML(respCls, version);
		route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version);
		
		// Add other Supported APIs here as created
	}
1287886
def routes_register(app, handler, *paths, methods=None, router=None, name=None):
    """"""
    if router is None:
        router = app.router

    handler = to_coroutine(handler)

    resources = []

    for path in paths:

        # Register any exception to app
        if isinstance(path, type) and issubclass(path, BaseException):
            app._error_handlers[path] = handler
            continue

        # Ensure that names are unique
        name = str(name or '')
        rname, rnum = name, 2
        while rname in router:
            rname = "%s%d" % (name, rnum)
            rnum += 1

        path = parse(path)
        if isinstance(path, RETYPE):
            resource = RawReResource(path, name=rname)
            router.register_resource(resource)

        else:
            resource = router.add_resource(path, name=rname)

        for method in methods or [METH_ANY]:
            method = method.upper()
            resource.add_route(method, handler)

        resources.append(resource)

    return resources
666889
private static Map<RouteDefinition, Method> getDefinitions(Class clazz) {

		Assert.notNull(clazz, "Missing class with JAX-RS annotations!");

		// base
		RouteDefinition root = new RouteDefinition(clazz);

		// go over methods ...
		Map<RouteDefinition, Method> output = new LinkedHashMap<>();
		for (Method method : clazz.getMethods()) {

			if (isRestCompatible(method)) { // Path must be present

				try {
					RouteDefinition definition = new RouteDefinition(root, method);
					output.put(definition, method);
				}
				catch (IllegalArgumentException e) {

					throw new IllegalArgumentException(getClassMethod(clazz, method) + " - " + e.getMessage());
				}
			}
		}

		return output;
	}
1022814
function addRouteFactory(router, method, end) {
  return (pattern, ...middlewares) => {
    if (typeof pattern === 'function') {
      middlewares = [pattern, ...middlewares];
      pattern = '/';
    }

    // create a route with multiple middlewares
    const route = compose(middlewares, { beforeRunMiddleware: (middleware, req, resp) => {
      const len = req.routePath ? req.routePath.length : 0;
      if (req.url.slice(0, len) !== req.routePath) return false;// url changed
      return true;
    } });
    route.method = method;

    const keys = [];
    const re = ptre(pattern, keys, { end, strict: false, sensitive: false });
    route.re = re;// used to test the remain of req.url
    route.keys = keys;

    router.routes.push(route);

    return router;
  };
}
1282508
function Route(method, route, fn) {
    this.method = method;
    this.route = route;
    this.fn = fn;

    return function (app) {
        var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
            utils.getRequestMiddlewares();

        if (method == "get") {
            app.get(route, middleware, fn)
        }
        else if (method == "post") {
            app.post(route, middleware, fn);
        }
//        var methodRoutes = app.routes[method];
//        return methodRoutes[methodRoutes.length - 1];
    };
}
1303990
function Route(path,content,operation){
	if(typeof(path) === 'string'){
		if(path === '*') path = '.*';
		path = new RegExp(path);
	}
	if(typeof(content) === 'string'){
		if(content === '*') content = '.*';
		content = new RegExp(content);
	}
	this.path = path;
	this.content = content;
	this.operation = operation;
}
127416
def handle_json_GET_routes(self, params):
    """"""
    schedule = self.server.schedule
    result = []
    for r in schedule.GetRouteList():
      result.append( (r.route_id, r.route_short_name, r.route_long_name) )
    result.sort(key = lambda x: x[1:3])
    return result
882569
def create_route(self, uri, sub_service):
        
        if uri not in self.routes.keys():
            logger.debug('Service ({0}): Creating routes'
                         .format(self.name))
            self.routes[uri] = {
                'regex': StackInABoxService.get_service_regex(self.base_url,
                                                              uri,
                                                              sub_service),
                'uri': uri,
                'handlers': StackInABoxServiceRouter(self.name,
                                                     uri,
                                                     None,
                                                     self)
            }
155280
function (routes) {
		var self = this;

	
		fs.readdirSync(this.middlewareBasePath()).filter(file => file.match(/\.js$/) || file.match(/\.coffee$/)).forEach(function (file) {
			var middlewareName = file.replace(/\.js$/, '').replace(/\.coffee$/, '');
			self.middlewares[middlewareName] = require(path.join(self.middlewareBasePath(), middlewareName));
		});


		for (var root in routes) {
			if (root && routes[root]) {
				for(var key in routes[root]) {
					var method = key.trim().split(' ')[0].toLowerCase();
					var routerMiddelware = routes[root][key];
					var endpoint;

					if (root == 'index') endpoint = ((key.trim().split(' ')[1].toLowerCase() != '/') ? key.trim().split(' ')[1].toLowerCase() : '/');
					else endpoint = '/' + root + ((key.trim().split(' ')[1].toLowerCase() != '/') ? key.trim().split(' ')[1].toLowerCase() : '');

					self.__endpoint__handler(method, endpoint, routerMiddelware);
				}
			}
		}
	}
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));
  }
283425
def register_subservice(self, uri, service):
        
        found = False

        self.create_route(uri, True)
        self.routes[uri]['handlers'].set_subservice(service)
767012
protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
            'namespace'  => $this->namespace,
            'prefix' => $this->prefix,
        ], function ($router) {
            require __DIR__.'/../Routes/web.php';
        });
    }
923874
function transformRoutes(routes) {
  if (typeof routes !== 'object') {
    throw new Error('Invalid route config');
  }
  var config = clone(routes);

  return Object.keys(config).map(function(name){
    var opt = config[name];
    // sugar for specifying fn
    if (typeof opt === 'function') {
      opt = {
        view: opt
      };
    } else if (typeof opt !== 'object') {
      throw new Error('Invalid route config for ' + name);
    }

    var defaultRoute = opt.defaultChild ? DefaultRoute({
      key: (opt.defaultChild.key || name + 'Default'),
      name: (opt.defaultChild.name || name + 'Default'),
      handler: opt.defaultChild.view
    }) : null;

    var notFoundRoute = opt.childNotFound ? NotFoundRoute({
      key: (opt.childNotFound.key || name + 'NotFound'),
      name: (opt.childNotFound.name || name + 'NotFound'),
      handler: opt.childNotFound.view
    }) : null;

    var children = (opt.children ? transformRoutes(opt.children) : []);
    if (defaultRoute) {
      children.push(defaultRoute);
    }
    if (notFoundRoute) {
      children.push(notFoundRoute);
    }
    return Route({
      key: name,
      name: name,
      path: opt.path,
      handler: opt.view
    }, children);
  });
}
650822
function loadRoutes() {
  try {
    var list = Crux.util.readDirectory(Component.appPath(this.config.path.routes), 'js'),
      self = this;
    if(list.length === 0) {
      return log.warn('Crux.server: component has no routes.');
    }
  } catch(e) {
    return;
  }

  list.forEach(function(routePath) {
    var routeObj = require(routePath);
    if(routeObj.skip === true) return;
    var httpRouteObj = self.createHttpRoute(routePath);
    if(!_.isFunction(routeObj)) {
      log.warn('Crux.server: Route %s does not export a function.', httpRouteObj.__rootPath);
      return;
    }
    routeObj(httpRouteObj);
    if(typeof self.routes[httpRouteObj.__namespace] !== 'undefined') {
      throw new Error("Route namespace " + httpRouteObj.__namespace + " previously registered.");
    }
    self.routes[httpRouteObj.__namespace] = httpRouteObj;
    routeCount++;
  });
  if(self.config.debug) {
    log.trace('Crux.server: %s route(s) loaded.', routeCount);
  }
}
916988
function routeDescription (route, index, group) {
   const meta = route.meta || {};
   const desc = meta.description;
   const extd = meta.extendedDescription;

   return [
      routeInfo(route.method, route.path, group.prefix),
      !desc ? '' : m('p', desc),
      !extd ? '' : m('p', m.trust( markdown( stripIndent(extd) ) ))
   ];
}
882713
public String route(String method) {
        String route = router.getReverseRouteFor(controller, method);
        if (route == null) {
            throw new TemplateProcessingException(ERR_FIND_ROUTE + controller.getClass().getName() +
                    "#" + method);
        }
        return route;
    }