Sha256: 22839504e15cbbcb718e4462a68036d99cc614dd464e4febf697ebfa5b689b64

Contents?: true

Size: 1.2 KB

Versions: 26

Compression:

Stored size: 1.2 KB

Contents

require 'faraday'

module Geminabox

  class TemplateFaradayAdapter < HttpAdapter

    def get(*args)
      adapter.get(*args)
    end

    def get_content(*args)
      response = adapter.get(*args)
      response.body
    end

    def post(*args)
      adapter.post(*args)
    end

    # Note that this configuration turns SSL certificate verification off.
    # To set up the adapter for your environment see:
    # https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates
    def set_auth(uri, username = nil, password = nil)
      connection = Faraday.new url: uri, ssl: {verify: false} do |faraday|
        faraday.adapter http_engine
        faraday.proxy(ENV['http_proxy']) if ENV['http_proxy']
      end
      connection.basic_auth username, password if username
      connection
    end

    def adapter
      @adapter ||= Faraday.new do |faraday|
        faraday.adapter http_engine
        faraday.proxy(ENV['http_proxy']) if ENV['http_proxy']
      end
    end

    def http_engine
      :net_http  # make requests with Net::HTTP
    end

    def options
      lambda {|faraday|
        faraday.adapter http_engine
        faraday.proxy(ENV['http_proxy']) if ENV['http_proxy']
      }
    end

  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
geminabox-1.4.1 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.4.0 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.3.1 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.3.0 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.2.0 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.1.1 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.1.0 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.0.1 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-1.0.0 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.15 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.14 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.13 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.11 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.10 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.9 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.8 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.7 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.6 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.5 lib/geminabox/http_adapter/template_faraday_adapter.rb
geminabox-0.13.4 lib/geminabox/http_adapter/template_faraday_adapter.rb