Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Various Faraday middlewares for my Faraday-based API wrappers

Fetching latest commit…

Cannot retrieve the latest commit at this time

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"
Something went wrong with that request. Please try again.