var jayson = require(__dirname + '/../..');
var format = require('util').format;

var methods = {
  // a method that prints every request
  add: function(a, b, callback) {
    callback(null, a + b);
  }
};

var server = jayson.server(methods, {
  router: function(method) {
    // regular by-name routing first
    if(typeof(this._methods[method]) === 'function') return this._methods[method];
    if(method === 'add_2') return this._methods.add.bind(this, 2);
  }
});

server.http().listen(3000);

var jayson = require(__dirname + '/../..');
var format = require('util').format;

var methods = {
  // a method that prints every request
  add: function(a, b, callback) {
    callback(null, a + b);
  }
};

var server = jayson.server(methods, {
  router: function(method) {
    // regular by-name routing first
    if(typeof(this._methods[method]) === 'function') return this._methods[method];
    if(method === 'add_2') {
      var fn = server.getMethod('add').getHandler();
      return jayson.Method(fn.bind(null, 2));
    }
  }
});

server.http().listen(3000);

Convert method routing example to new method definition
Convert method routing example to new method definition
