Returns a router for a given HTTP request.
511893
def MatchRouter(self, request):
    """"""
    router = api_auth_manager.API_AUTH_MGR.GetRouterForUser(request.user)
    routing_map = self._GetRoutingMap(router)

    matcher = routing_map.bind(
        "%s:%s" %
        (request.environ["SERVER_NAME"], request.environ["SERVER_PORT"]))
    try:
      match = matcher.match(request.path, request.method)
    except werkzeug_exceptions.NotFound:
      raise ApiCallRouterNotFoundError("No API router was found for (%s) %s" %
                                       (request.path, request.method))

    router_method_metadata, route_args_dict = match
    return (router, router_method_metadata,
            self._GetArgsFromRequest(request, router_method_metadata,
                                     route_args_dict))
923903
public function getRouting(Request $request)
    {
        // Check if router class has been defined in config parameters
        if ($this->getConfig()->hasParameter('routing')) {
            $routerClass = $this->getConfig()->getParameter('routing');

            $router = new $routerClass();

            return $router;
        }

        $router = new Router($request);

        return $router;
    }
938406
function(router, req, res) {
    var routeFound = false,
      url = req.url.toString(),
      method = req.method;
    for (var i = 0; i < router.routes.length; i++) {
      var route = router.routes[i];
      if (url.indexOf(route.route) != -1 && route.method == method) {
        if (url != '/' && route.route == '/') {
          continue;
        }
        if (url != route.route && !route.hasObject) {
          continue;
        }
        if (method === 'GET') {
          req.body = {};
          if (route.hasObject) {
            req.body[route.objectName] = basename(url);
          }
          route.callback(req, res);
          routeFound = true;
          break;
        } else {
          ReqToObject(req, res, route);
          routeFound = true;
          break;
        }
      }
    }
    return routeFound;
  }
810552
def http(self, *args, **kwargs):
        """"""
        kwargs['api'] = self.api
        return http(*args, **kwargs)
1017943
def router(self):
        """"""
        for server in self._routers:
            info = Servers().info(server)
            if info['procInfo'].get('alive', False):
                return {'id': server, 'hostname': Servers().hostname(server)}
908742
def proxy(request):
    """"""

    # TODO: don't hardcode http
    uri = "http://" + HOST + request.META['PATH_INFO']
    if request.META['QUERY_STRING']:
        uri += '?' + request.META['QUERY_STRING']

    headers = {}
    for name, val in six.iteritems(request.environ):
        if name.startswith('HTTP_'):
            name = header_name(name)
            headers[name] = val

    # TODO: try/except
    http = Http()
    http.follow_redirects = False
    logger.debug("GET for: %s" % uri)
    info, content = http.request(uri, 'GET', headers=headers)
    response = HttpResponse(content, status=info.pop('status'))

    for name, val in info.items():
        if not is_hop_by_hop(name):
            response[name] = val
    logger.info("PROXY to: %s" % uri)
    return response
1192745
function(routeName, models, queryParams) {
        var router = this.router;
        return router.isActive.apply(router, arguments);
      }
141698
def _get(self, url, params={}):
        """"""
        r = requests.get(self._api_prefix + url,
            params=params,
            headers=self.headers,
            auth=self.auth,
        )
        return self._action(r)
404751
public List<ProviderInfo> route(SofaRequest request, List<ProviderInfo> providerInfos) {
        for (Router router : routers) {
            providerInfos = router.route(request, providerInfos);
        }
        return providerInfos;
    }
1281967
function Router_process(method, parsedUrl, headers) {

        return this.parseRequest(method, parsedUrl, headers)
            .then(function (routeRule) {
                if (Type.isArray(routeRule) && routeRule.length === 2) {
                    return Promise.resolve(routeRule);
                }
                // only on not found throw an error 404
                throw new error.HttpError(404, core.toObject(routeRule), 'Not found');
            }, function (e) {
                throw new error.HttpError(500, {}, 'Not found', e);
            });
    }
1258077
def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]:
        
        if request is not None:
            host = request.host
            return self.url_map.bind_to_request(
                request.scheme, host, request.method, request.path, request.query_string,
            )

        if self.config['SERVER_NAME'] is not None:
            return self.url_map.bind(
                self.config['PREFERRED_URL_SCHEME'], self.config['SERVER_NAME'],
            )
        return None
956687
def get(url: str, *args, **kwargs) -> tuple:
    """"""
    return RequestsHelper.request(url, "get", *args, **kwargs)
257932
function router(rpc, handlers, req, res) {
  var $       = rpc.$;
  var api     = rpc.api;
  var request = api.handle(req.method, req.url);
  var dom     = domain.create();

  // the request handler doesn't exit
  // TODO: hoist response logic
  if (!request) {
    res.statusCode = 404;
    res.end();
    return;
  }

  var context = new Context(); // TODO: hoist to own module
  var handle  = request.handle;
  var params  = {};

  // TODO: hoist logic to 'union' module
  var key;
  for(key in request.params) params[key] = request.params[key];
  for(key in request.query)  params[key] = request.query[key];

  var future = $.future();

  future.setWritable(res);
  future.setReadable(req);

  // TODO: extract request making logic
  res.setHeader('Transfer-Encoding' , 'chunked');
  res.setHeader('Content-Type'      , 'application/json');

  dom.on('error', function (err) {
    var statusCode = err.statusCode;

    // only catch known errors, re-throw unexpected errors
    if (!statusCode) throw err;

    // TODO: hoist response logic
    res.statusCode = statusCode;
    res.write(JSON.stringify(err));
    res.end();
  });

  // domain should handle all route errors
  dom.run(function () {
    handlers[handle](future, params, context);
  });
}
1329117
def _constructUrl(self, route):
        """"""
        return liburls.api(
            self.options['rootUrl'],
            self.serviceName,
            self.apiVersion,
            route.rstrip('/'))
1275171
function routeTo(url) {
	let didRoute = false;
	for (let i=0; i<ROUTERS.length; i++) {
		if (ROUTERS[i].routeTo(url)===true) {
			didRoute = true;
		}
	}
	for (let i=subscribers.length; i--; ) {
		subscribers[i](url);
	}
	return didRoute;
}
652282
public ServiceCall router(Class<? extends Router> routerType) {
    ServiceCall target = new ServiceCall(this);
    target.router = Routers.getRouter(routerType);
    return target;
  }
858623
def router(name, args, kwargs, options, task=None, **kw):
    '''
    
    '''
    # Fetch task by name if necessary
    task = task or celery.tasks.get(name)
    if not task:
        return
    # Single route param override everything
    if task.route:
        queue = task.route.split('.', 1)[0]
        return {'queue': queue, 'routing_key': task.route}
    # queue parameter, routing_key computed if not present
    if task.default_queue:
        key = task.default_routing_key
        key = key or '{0.default_queue}.{0.name}'.format(task)
        return {'queue': task.default_queue, 'routing_key': key}
    # only routing_key, queue should not be returned to fallback on default
    elif task.default_routing_key:
        return {'routing_key': task.default_routing_key}