Ruby client library for ServiceStack - a simple, fast, versatile and highly productive full-featured Web and Web Services Framework. ServiceStack Ruby HTTP Client Library for consuming ServiceStack web services.
Add this line to your application's Gemfile:
gem 'servicestack'And then execute:
$ bundle install
Or install it yourself as:
$ gem install servicestack
require 'servicestack'
# Create a client instance
client = ServiceStack::Client.new('https://api.example.com')
# Make a GET request
response = client.get('users')
# Make a POST request
response = client.post('users', { name: 'John Doe', email: '[email protected]' })
# Make a PUT request
response = client.put('users/1', { name: 'Jane Doe' })
# Make a PATCH request
response = client.patch('users/1', { email: '[email protected]' })
# Make a DELETE request
response = client.delete('users/1')# GET request with query parameters
response = client.get('users', { page: 1, per_page: 10 })# Configure custom timeouts (in seconds)
client = ServiceStack::Client.new(
'https://api.example.com',
timeout: 30, # Request timeout
open_timeout: 15 # Connection timeout
)
# Or set timeouts after initialization
client.timeout = 30
client.open_timeout = 15The client raises ServiceStack::Error for HTTP errors:
begin
response = client.get('users/999')
rescue ServiceStack::Error => e
puts "Error: #{e.message}"
endAfter checking out the repo, run bundle install to install dependencies. Then, run rake test to run the tests.
To install this gem onto your local machine, run bundle exec rake install.
bundle exec rake testbundle exec rake buildThis will create a .gem file in the pkg directory.
To release a new version:
- Update the version number in
lib/servicestack/version.rb - Update the
CHANGELOG.mdwith the changes - Commit the changes
- Run
bundle exec rake releaseto create a git tag, build the gem, and push it to RubyGems
Bug reports and pull requests are welcome on GitHub at https://github.com/ServiceStack/servicestack-ruby.
The gem is available as open source under the terms of the MIT License.