Skip to content

handlers inside of handlers #16

@mcwhittemore

Description

@mcwhittemore

If we could nest handers inside of handlers

{hash_recursive_make:a_make:b}

handler['recursive'] = function(req, optStr, next) {
  var opts = optStr.split('_');

  for(var i=0; i<opts.length; i++) {
    if(opts[i].indexOf('make:') === 0) {
      var username = opts[i].replace('make:', '');
      return makeUser(username, function(err, userid) {
        if(err) next(err);
        opts[i] = userid;
        return handler['recursive'](req, opts.join('_'), next);
      }
    }
  }

  return hashOf(opts);
}

would be

{hash_{user_a}_{user_b}}

hander['hash'] = function(req, optsStr, next) {
   return hashOf(optsStr.split('_'));
}

hander['user'] = function(req, username, next) {
   makeUser(username, next);
}

Does this seem like something we want to support? If so, I can create a PR to make it happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions