Sha256: 6d9fbb84d73b9034005785b94db51aa80bf1e860d28724b6d3a008c3820c55bb
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
require 'openssl' require 'faraday' require 'faraday_middleware' require 'yajl' module SparkApi # =Connection # Mixin module for handling http connection information module Connection # Main connection object for running requests. Bootstraps the Faraday abstraction layer with # our client configuration. def connection(force_ssl = false) opts = { :headers => headers } domain = @endpoint if(force_ssl || self.ssl) opts[:ssl] = {:verify => false } opts[:url] = @endpoint.sub /^http:/, "https:" else opts[:url] = @endpoint.sub /^https:/, "http:" end conn = Faraday::Connection.new(opts) do |builder| builder.adapter Faraday.default_adapter builder.use SparkApi::FaradayExt::SparkMiddleware end SparkApi.logger.debug("Connection: #{conn.inspect}") conn end # HTTP request headers for client requests def headers { :accept => 'application/json', :content_type => 'application/json', :user_agent => Configuration::DEFAULT_USER_AGENT, Configuration::X_SPARK_API_USER_AGENT => user_agent } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spark_api-1.0.4 | lib/spark_api/connection.rb |
spark_api-1.0.2 | lib/spark_api/connection.rb |
spark_api-1.0.1 | lib/spark_api/connection.rb |
spark_api-1.0.0 | lib/spark_api/connection.rb |