Permalink
Browse files

Remove misplaced code in example

  • Loading branch information...
1 parent 7b4c7f5 commit 4b284f8d6d0d8a3a947b5461e67362be1913bd6b @remiprev committed Jun 14, 2012
Showing with 5 additions and 41 deletions.
  1. +5 −41 examples/twitter-oauth/app.rb
@@ -20,11 +20,11 @@ def on_complete(env)
}
# Initialize API
-Her::API.setup :url => "https://api.twitter.com/1/" do |connection|
- connection.use FaradayMiddleware::OAuth, TWITTER_CREDENTIALS
- connection.use Faraday::Request::UrlEncoded
- connection.use TwitterParser
- connection.use Faraday::Adapter::NetHttp
+Her::API.setup :url => "https://api.twitter.com/1/" do |builder|
+ builder.use FaradayMiddleware::OAuth, TWITTER_CREDENTIALS
+ builder.use Faraday::Request::UrlEncoded
+ builder.use TwitterParser
+ builder.use Faraday::Adapter::NetHttp
end
# Define classes
@@ -48,39 +48,3 @@ def username
@tweets = Tweet.mentions
haml :index
end
-
-############################################
-
-# config/initializers/her.rb
-Her::API.setup :url => "https://api.example.com" do |connection|
- connection.use MyAuthentication
- connection.use Faraday::Request::UrlEncoded
- connection.use Her::Middleware::DefaultParseJSON
- connection.use Faraday::Adapter::NetHttp
-end
-
-# app/controllers/application_controller.rb
-class ApplicationController < ActionController::Base
- before_filter do
- MyApp.current_user = session[:user_id] ? User.find(session[:user_id]) : nil
- end
-end
-
-# lib/my_app.rb
-class MyApp
- def self.current_user=(user)
- @current_user = user
- end
-
- def self.current_user
- @current_user
- end
-end
-
-# lib/my_authentication.rb
-class MyAuthentication < Faraday::Middleware
- def call(env)
- env[:request_headers]["X-API-Token"] = MyApp.current_user.token if MyApp.current_user?
- @app.call(env)
- end
-end

0 comments on commit 4b284f8

Please sign in to comment.