nwarlen / consul-client

Client code for service discovery and invocation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consul-client Build Status

Client code for service discovery and invocation

Example

'use strict';

var consulClient = require('consul-client');

var consulHost = 'my.consul.com'; // e.g 172.x.x.x:8500
var consulRequest = consulClient(consulHost);

var config = {
  serviceName: 'users',
  version: '1.0.0',
  endpoint: 'users/login',
  method: 'POST',
  body: {
    username: 'will',
    password: 'p@ssword'
  }
};

// Discovers an instance of the users service
// and POSTs body to it's /users/login route.
consulRequest(config)
  .then(console.log) // log successes
  .catch(console.log); // catch and log all errors

About

Client code for service discovery and invocation

License:MIT License


Languages

Language:JavaScript 100.0%