Various Faraday middlewares for my Faraday-based API wrappers
Ruby
Pull request Compare This branch is 1 commit ahead, 221 commits behind lostisland:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gemtest
.gitignore
.rspec
.travis.yml
CHANGELOG.md
Gemfile
LICENSE.md
README.md
Rakefile
faraday_middleware.gemspec

README.md

Faraday Middleware

A collection of some useful Faraday middleware

Installation

gem install faraday_middleware

Examples

Let's decode the response body with MultiJson!

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

response = connection.get do |request|
  request.url '/users/show.json', :screen_name => 'pengwynn'
end

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

Want to ditch the brackets and use dot notation? Mashify it!

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

response = connection.get do |request|
  request.url '/users/show.json', :screen_name => 'pengwynn'
end

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