运行Presenter

@inner
@param {Object} route 路由信息
@param {Object} route.action Presenter配置
@param {Object} index 路由信息序列
@param {string} path 请求路径
@param {Object} query 请求参数
@param {Object} res 请求响应对象
@param {Function} next 执行下一个路由处理器
349617
function run(route, index, path, query, res, next) {
    mm.create(route.action).then(
        function (presenter) {
            var ele = new Element('div');

            function finish() {
                var model = presenter.model;
                res.html = ele.outerHTML;
                res.data = model.store;
                res.routeIndex = index;
                next();
            }

            presenter
                .enter(ele, path, query)
                .then(finish, next);
        },
        next
    ).then(null, next);
}
954051
function handleQueryParameters(request, response, next) {
	if (args.query === true && Object.keys(request.query).length > 0) {
		request.path += '/' + Object.keys(request.query).join('_') + '.json';
	}
	return next();
}
731948
function adaptForRouter(val, key) {
  key = key.split(/\s+/);
  if (typeof val === 'string' || typeof val === 'function' || Array.isArray(val)) {
    val = {
      path: key[0],
      method: key[1],
      controller: val
    };
  } else if (typeof val === 'object') {
    if (!val.path) {
      val.path = key[0];
    }
    if (!val.method) {
      val.method = key[1];
    }
  } else {
    throw new Error(`Problem with route "${key}"`);
  }
  return val;
}
1238895
function(route, name, callback) 
	{
		var regExp = conbo.isRegExp(route) ? route : this.__routeToRegExp(route);
		
		if (!callback) 
		{
			callback = this[name];
		}
		
		if (conbo.isFunction(name)) 
		{
			callback = name;
			name = '';
		}
		
		if (!callback) 
		{
			callback = this[name];
		}
		
		this.__history.addRoute(regExp, (function(path)
		{
			var args = this.__extractParameters(regExp, path);
			
			var params = conbo.isString(route) 
				? conbo.object((route.match(/:\w+/g) || []).map(function(r) { return r.substr(1); }), args) 
				: {}
				;
			
			callback && callback.apply(this, args);
			
			var options = 
			{
				router:		this,
				route:		regExp,
				name:		name,
				parameters:	args,
				params:		params,
				path:		path
			};
			
			this.dispatchEvent(new conbo.ConboEvent('route:'+name, options));
			this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.ROUTE, options));
			
		}).bind(this));
		
		return this;
	}
860481
function RouteRule_parseRequest(method, url) {

        var matches,
            route,
            key,
            result = [],
            escape = [],
            params = {},
            current;
        //match pathname
        matches = this.match(this.pattern, this.trim(url.pathname, '/'));


        if (!matches.length || !this.checkMethod(method)) {
            return false;
        }
        params = url.query;


        for (key in params) {
            current = this.find(matches, key);
            if (!current || current.value === '') {
                matches.push({
                    key: key,
                    value: params[key]
                });
            }
        }

        matches.forEach(function (item) {
            var current = this.find(this.routeParams, item.key);
            if (current) {
                escape.push({
                    key: '<' + current.key + '>',
                    value: item.value
                });
                delete params[item.name];
            } else if (this.find(this.paramRules, item.key)) {
                params[item.key] = item.value;
            }
        }.bind(this));


        if (this.routeParams.length) {
            route = this.escape(this.route, escape);
        } else {
            route = this.route;
        }

        result.push(route);
        result.push(params);

        return result;
    }
652335
function action(route) {

    if(!route){
        throw new Error('Please pass an action');
    }

    return ({ constructor }, method, { value }) => {

        let Class = constructor;

        initCoreMap(storage, Class);
        initActionMap(storage, Class);

        let map = storage.get(Class);

        map.get('@action').get('events').push([
            `${method} ${route}`, value
        ]);

        /**
         * ### Ensure "registerCallback('created', ..." (see below) registered only once ###
         * This function will called every time if an event registered e.g. @on('click .foo')
         * but registerOnCreatedCallback can only call once because we want only Create
         * one Eventhandler
         */
        if(map.get('@action').get('callbacksDefined')){
            return;
        }

        map.get('@callbacks').get('created').push(domNode => {

            let events = map.get('@action').get('events');
            domNode.$router = Router.create({
                routes : events,
                scope  : domNode,
                bind   : domNode,
            });
        });

        map.get('@callbacks').get('attached').push(domNode => {

            if(domNode.$router.initialized()){
                return;
            }

            let events = map.get('@action').get('events');
            let config = Router.makeConfig({
                routes : events,
                scope  : domNode,
                bind   : domNode,
            });

            /**
             * Using the same instance is 30% faster in
             * (Chrome, Opera) and no difference in Firefox
             * @see: https://jsperf.com/new-class-vs-singleton
             */
            domNode.$router.reinit(config);

        });

        map.get('@callbacks').get('detached').push(domNode => {
            domNode.$router.destroy();
        });

        map.get('@action').set('callbacksDefined', true);
    }
}
313665
function Route(props) {
  props = props ? merge({}, props) : {};

  var path = props.path;

  if (typeof path === 'string') {
    path = path.replace(slashes, '');
  }

  delete props.path;

  var view = props.view;
  delete props.view;

  var viewPromise = props.viewPromise;
  delete props.viewPromise;

  var name = props.name;
  delete props.name;

  var __scope = props.__scope;
  delete props.__scope;

  var args = Array.prototype.slice.call(arguments, 1);

  var children = [];

  // so we support passing routes as arguments and arrays
  for (var i = 0, len = args.length; i < len; i++) {
    if (Array.isArray(args[i])) {
      children = children.concat(args[i]);
    } else {
      children.push(args[i]);
    }
  }

  var route = {path, name, view, viewPromise, props, children, __scope};
  buildNameIndex(route);
  return route;
}
842724
function go(path, title, shouldReplace) {
  // Server-side usage: directly execute handlers for the path
  if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))

  path = route._.base + normalize(path)
  title = title || doc.title
  // browsers ignores the second parameter `title`
  shouldReplace
    ? hist.replaceState(null, title, path)
    : hist.pushState(null, title, path)
  // so we need to set it manually
  doc.title = title
  routeFound = false
  emit()
  return routeFound
}
4138
private static function routeAction()
    {
        $actionQueryString = Request::getInputValue("do", false, true);
        $actionQuery = Actions::parseActionQueryString($actionQueryString);
        
        Addons::executeComponentFunction($actionQuery->name, $actionQuery->method, @$actionQuery->arguments);
    }
565496
def route(event_name, aggregate_id, **data)
      @routes[event_name].each do |listener|
        listener = listener.new if listener.is_a?(Class)
        begin
          listener.public_send(:"on_#{event_name}", aggregate_id, **data)
        rescue RuntimeError => e
          log "Error handling event #{event_name.inspect}: #{e}"
        end
      end
    end
271157
function emit (route) {
    var matched = match(route)

    var args = new Array(arguments.length)
    args[0] = matched.params
    for (var i = 1; i < args.length; i++) {
      args[i] = arguments[i]
    }

    return matched.cb.apply(matched.cb, args)
  }
482391
function routeAndCorrectedPathIndexes(routes, pathIndex) {
        for(var n=0; n<routes.length; n++) {
            var pathIndexes = routes[n].pathIndexes
            if(pathIndexes.start <= pathIndex && pathIndex <= pathIndexes.end || routes[n].route.isDefault) {
                return {routeIndex: n, pathIndex: pathIndexes.start}
            }
        }
        // else
        return {routeIndex: routes.length, pathIndex: pathIndex}
    }
1063436
function makeHref(to, params, query) {
    return this.context.router.makeHref(to, params, query);
  }
850384
function ActivatedRoute(url, params, queryParams, fragment, data, outlet, component, futureSnapshot) {
        this.url = url;
        this.params = params;
        this.queryParams = queryParams;
        this.fragment = fragment;
        this.data = data;
        this.outlet = outlet;
        this.component = component;
        this._futureSnapshot = futureSnapshot;
    }
636712
function(req, res, route) {
    req.on('data', function(data) {
      req.body = queryStringToJSON(data.toString());
      route.callback(req, res);
    });
  }
996893
@Override
    public Result call(final Route route, final RequestContext context) throws Exception {
        URI redirectedURI = rewriteURI(context.request());
        logger.debug("Redirecting request - rewriting {} to {}", context.request().uri(), redirectedURI);
        if (redirectedURI == null) {
            return onRewriteFailed(context);
        }
        return Results.redirect(redirectedURI.toString());
    }
692021
function applyRoutes(cmd, route, _app) {
    cmd = cmd.split(' ');
    var url = cmd[1] || cmd[0];
    var method = cmd.length < 2 ? 'get' : cmd[0];

    // Support regex expression
    var matches = /\((.*)\)/.exec(url);
    if(matches !== null && matches[1]) {
        url = new RegExp(matches[1]);
    }

    _app[method](url, function(req, res, next) {
        route.call({
            app: _app, req: req, res: res, next: next,
            //TODO:
            render: _app.get('render manager').list(res)
        }, req, res, next);
    });
}