# Faraday Middleware

Collection of [Faraday](http://github.com/technoweenie/faraday) middlewares I've been using in some of my API wrappers


## Installation

    sudo gem install faraday_middleware


#### Some examples

Let's decode the response body with [MultiJson](http://github.com/intridea/multi_json)

    conn = Faraday::Connection.new(:url => 'http://api.twitter.com/1') do |builder|
      builder.adapter Faraday.default_adapter
      builder.use Faraday::Response::MultiJson
    end

    resp = conn.get do |req|
      req.url '/users/show.json', :screen_name => 'pengwynn'
    end

    u = resp.body
    u['name']
    # => "Wynn Netherland"


Want to ditch the brackets and use dot notation? [Mashify](http://github.com/intridea/hashie) it!

    conn = Faraday::Connection.new(:url => 'http://api.twitter.com/1') do |builder|
      builder.adapter Faraday.default_adapter
      builder.use Faraday::Response::MultiJson
      builder.use Faraday::Response::Mashify
    end

    resp = conn.get do |req|
      req.url '/users/show.json', :screen_name => 'pengwynn'
    end

    u = resp.body
    u.name
    # => "Wynn Netherland"
# Faraday Middleware

Collection of [Faraday](http://github.com/technoweenie/faraday) middlewares I've been using in some of my API wrappers


## Installation

    sudo gem install faraday_middleware


#### Some examples

Let's decode the response body with [MultiJson](http://github.com/intridea/multi_json)

    conn = Faraday::Connection.new(:url => 'http://api.twitter.com/1') do |builder|
      builder.adapter Faraday.default_adapter
      builder.use Faraday::Response::Parse
    end

    resp = conn.get do |req|
      req.url '/users/show.json', :screen_name => 'pengwynn'
    end

    u = resp.body
    u['name']
    # => "Wynn Netherland"


Want to ditch the brackets and use dot notation? [Mashify](http://github.com/intridea/hashie) it!

    conn = Faraday::Connection.new(:url => 'http://api.twitter.com/1') do |builder|
      builder.adapter Faraday.default_adapter
      builder.use Faraday::Response::Parse
      builder.use Faraday::Response::Mashify
    end

    resp = conn.get do |req|
      req.url '/users/show.json', :screen_name => 'pengwynn'
    end

    u = resp.body
    u.name
    # => "Wynn Netherland"

Update to reflect middlware name change in 0.2.0
Update to reflect middlware name change in 0.2.0

Faraday::Response::MultiJson -> Faraday::Response::Parse
