Class: Faraday::CommonRequest
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::CommonRequest
- Defined in:
- lib/href_preview/faraday_common_request.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *args) ⇒ CommonRequest
constructor
A new instance of CommonRequest.
Constructor Details
#initialize(app, *args) ⇒ CommonRequest
Returns a new instance of CommonRequest.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/href_preview/faraday_common_request.rb', line 18 def initialize(app, *args) @app = app @options = args.shift || {} @options.merge!( :user_agent => ( "Mozilla/5.0 (compatible; " + "HRefPreview/#{HRefPreview::VERSION::STRING}; " + "+https://github.com/sporkmonger/href-preview)" ), :accept => "*/*" ) @user_agent = @options[:user_agent] @accept = @options[:accept] end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/href_preview/faraday_common_request.rb', line 33 def call(env) env[:request_headers].merge!('User-Agent' => @user_agent) env[:request_headers].merge!('Accept' => @accept) response = @app.call env response end |