0.4.1 • Published 12 years ago

amino-driver-http v0.4.1

Weekly downloads
15
License
-
Repository
github
Last release
12 years ago

amino-request-http allows you to use HTTP as a transport for amino requests.

**note: this driver must be used in conjunction with a pub/sub driver. See amino-pubsub-redis as an example.

Usage

serve-sprocket.js

// Create a sprocket service.
var amino = require('amino')
  .use(require('amino-request-http'))
  .use(require('amino-pubsub-redis'), {host: 'localhost', port: 6379});

amino.respond('sprockets', function(router, spec) {
  // router is a director router.
  // @see https://github.com/flatiron/director
  router.get('/:id', function(id) {
    // amino adds the helpers json(), text(), and html().
    this.res.json({id: id});
  });
});

get-sprocket.js

// Request a sprocket from the sprocket service.
var amino = require('amino')
  .use(require('amino-request-http'))
  .use(require('amino-pubsub-redis'), {host: 'localhost', port: 6379});

// amino.request() is the same as github.com/mikeal/request, except
// it can handle the amino:// protocol, which uses virtual hosts defined
// with amino.respond().
amino.request('amino://sprockets/af920c').pipe(process.stdout);