MessageExchange
Use MessageExchange to simplify the passing of JSON-based messages between HTTP based applications.
Installation
Add this line to your application's Gemfile:
gem 'message_exchange', git: '[email protected]:onthebeach/message_exchange.git'
And then execute:
$ bundle
Or install it yourself as:
$ gem install message_exchange
Usage
Craft your request, replacing the class with one of Get
, Post
, Put
or Delete
.
request = MessageExchange::Get.new(url_string, params_hash)
Consume the response:
response = request.response
response.status # => the HTTP response code
response.success? # => Boolean (based on 20x response code)
response.body # => some stuff you probably wanted
Todo
- Implement other HTTP v1.1 methods:
Patch
,Options
,Head
,Trace
orConnect
. - Better error handling; currently only catches request timeouts.
- Configurable timeouts.
- Configurable headers.
- Configurable ports (instead of just port 80).
- HTTP/HTTPS support.
Contributing
- Fork it
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create new Pull Request