lib-http-api
v0.0.2
Published
## install
Downloads
10
Readme
lib-http-api
install
npm install --save lib-http-api
usage
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.