lib-http-api

## install

lib-http-api

npm install --save lib-http-api

define an interface

var search = {
  method : 'GET',
  route  : '/search/:query',
  options: {
    limit: 100,
    order: 'asc'
  }
};

create the api

var API = require('lib-http-api')();
var api = API.New();
 
api.add('search', search);

create the client request

api.request('search', {query: 'spicy+noodles'}, {order: 'desc'});
// { path   : '/search/spicy+noodles?order=desc&limit=100', 
//   method : 'GET', 
//   host   : 'localhost', 
//   port   : 100 } 

switch off a server request

api.handle('GET', '/search/spicy+noodles?order=desc&limit=100');
// { handle: 'search', 
//   params: { query: 'spicy+noodles' }, 
//   query: { order: 'desc', limit: '100' } } 

You'll want to associate the tokens returned with route handlers.