Announcing rest-client-components


Cyril Rohr <cyril.rohr@...>
 

Hello,

I just released a small gem called rest-client-components that enables the use of any Rack middleware in front of RestClient and I thought it may be of interest for this list's subscribers.

Examples of usage include transparent Caching with cache invalidation on non-GET requests (thanks to Rack::Cache), transparent Logging (using something like Rack::CommonLogger or a logging middleware of your own), transparent Parsing of body responses based on the returned Content-Type, etc.

You just have to enable the needed component(s) before making your requests as usual, e.g. with Rack::Cache:
RestClient.enable Rack::Cache, {whatever options supported by Rack::Cache}
then
RestClient.get "http://some/resource"

You may enable/disable as many middleware as you wish.

Code and documentation can be found at http://github.com/crohr/rest-client-components

Cyril
--
http://github.com/crohr


"Nicolás Sanguinetti <hi@...>
 

Why not RestClient.use(Middleware), to use the same API rack uses?

Great idea, btw :)

On Sun, Jan 10, 2010 at 3:20 PM, Cyril Rohr <cyril.rohr@...> wrote:
Hello,

I just released a small gem called rest-client-components that enables the use of any Rack middleware in front of RestClient and I thought it may be of interest for this list's subscribers.

Examples of usage include transparent Caching with cache invalidation on non-GET requests (thanks to Rack::Cache), transparent Logging (using something like Rack::CommonLogger or a logging middleware of your own), transparent Parsing of body responses based on the returned Content-Type, etc.

You just have to enable the needed component(s) before making your requests as usual, e.g. with Rack::Cache:
RestClient.enable Rack::Cache, {whatever options supported by Rack::Cache}
then
RestClient.get "http://some/resource"

You may enable/disable as many middleware as you wish.

Code and documentation can be found at http://github.com/crohr/rest-client-components

Cyril
--
http://github.com/crohr


Cyril Rohr <cyril.rohr@...>
 

On Jan 10, 2010, at 7:35 PM, Nicolás Sanguinetti wrote:

Why not RestClient.use(Middleware), to use the same API rack uses?

Great idea, btw :)
hum... maybe because I needed a "disable" method... and I didn't find
a proper antonym to the verb "use" :-)

Thanks for your comment.

Cyril
--
http://github.com/crohr