
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
rest-client-components
Advanced tools
= rest-client-components
RestClient on steroids !
Want to add transparent HTTP caching to the rest-client[http://github.com/archiloque/rest-client] gem ? It's as simple as: require 'restclient/components' require 'rack/cache' RestClient.enable Rack::Cache RestClient.get "http://some/cacheable/resource"
Want to log the requests in the commonlog format ? require 'restclient/components' RestClient.enable Rack::CommonLogger, STDOUT RestClient.get "http://some/resource"
Want to enable both ? require 'restclient/components' require 'rack/cache' RestClient.enable Rack::CommonLogger, STDOUT RestClient.enable Rack::Cache RestClient.get "http://some/cacheable/resource"
This works with any Rack middleware, thus you can reuse the wide range of existing Rack middleware to add functionalities to RestClient with very little effort. The order in which you enable components will be respected.
Note that the rest-client behaviour is also respected: you'll get back a RestClient::Response or RestClient exceptions as a result of your requests. If you prefer a more rack-esque approach, just disable the Compatibility component, and you will get back a response conform to the Rack SPEC: require 'restclient/components' RestClient.disable RestClient::Rack::Compatibility status, header, body = RestClient.get('http://some/url') In that case, you will only get exceptions for connection or timeout errors (RestClient::ServerBrokeConnection or RestClient::RequestTimeout)
See the examples folder for more details.
= Installation
gem install rest-client-components gem install rack-cache # if you want to use Rack::Cache
= Usage Example with Rack::Cache, and Rack::CommonLogger
require 'restclient/components' require 'rack/cache'
RestClient.enable Rack::CommonLogger
RestClient.enable Rack::Cache, :metastore => 'file:/tmp/cache/meta', :entitystore => 'file:/tmp/cache/body'
RestClient.get 'http://some/cacheable/resource'
resource = RestClient::Resource.new('http://some/cacheable/resource')
resource.get # get from origin server, and cache if possible resource.get # get from cache, if still fresh. resource.put(...) # will automatically invalidate the cache, so that a subsequent GET request on the same resource does not return the cached resource resource.get # get from origin server, and cache if possible
resource.get(:cache_control => 'no-cache') # explicitly tells to bypass the cache, requires rack-cache >= 0.5 and :allow_reload => true option
resource.delete(...) # will invalidate the cache resource.get # should raise a RestClient::ResourceNotFound exception
Now, you just need to make your resources cacheable, so unless you've already taken care of that, do yourself a favor and read:
= Dependencies
= COPYRIGHT
Copyright (c) 2009-2010 Cyril Rohr. See LICENSE for details.
FAQs
Unknown package
We found that rest-client-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.