-
Notifications
You must be signed in to change notification settings - Fork 6
Clients
adrian-gomez edited this page Sep 16, 2014
·
1 revision
Services build with angus can be consumed with anything that can issue and parse HTTP requests.
This is an example to get the users list exposed by angus demo using curl:
$ curl http://localhost:9292/demo/api/0.1/users
{"status":"success","users":[{"id":1,"name":"Bon Scott"},{"id":2,"name":"Brian Johnson"}]}
But a big bonus of using documented services is that you can easily create automated clients for them. And with this in mind be have done just that.
[angus-remote] (https://github.com/Moove-it/angus-remote) is a dynamic angus remote client generator. So invoking angus applications is almost as easy (if not more) than developing an API with angus.
Lets do the same as before but using angus-remote:
$ vim remote_demo.rb
require 'angus-remote'
remote_service = Angus::Remote::ServiceDirectory.lookup({ code_name: 'demo',
api_url: 'http://localhost:9292/demo/api/0.1/',
doc_url: 'http://localhost:9292/demo/doc/0.1/' })
users = remote_service.get_users.users
users.each do |user|
puts "#{user.id} => #{user.name}"
end
$ gem install angus-remote
$ ruby remote_demo.rb
1 => Bon Scott
2 => Brian Johnson
This is just a little example, for the full documentation visit [angus-remote GitHub page] (https://github.com/Moove-it/angus-remote)