Module: Github::Connection
- Extended by:
- Connection
- Includes:
- Constants
- Included in:
- Connection
- Defined in:
- lib/github_api/connection.rb
Overview
Specifies Http connection options
Constant Summary collapse
- ALLOWED_OPTIONS =
[ :headers, :url, :params, :request, :ssl ].freeze
Constants included from Constants
Github::Constants::ACCEPT, Github::Constants::ACCEPTED_OAUTH_SCOPES, Github::Constants::ACCEPT_CHARSET, Github::Constants::CACHE_CONTROL, Github::Constants::CONTENT_LENGTH, Github::Constants::CONTENT_TYPE, Github::Constants::DATE, Github::Constants::ETAG, Github::Constants::HEADER_LAST, Github::Constants::HEADER_LINK, Github::Constants::HEADER_NEXT, Github::Constants::LOCATION, Github::Constants::META_FIRST, Github::Constants::META_LAST, Github::Constants::META_NEXT, Github::Constants::META_PREV, Github::Constants::META_REL, Github::Constants::OAUTH_SCOPES, Github::Constants::PARAM_PAGE, Github::Constants::PARAM_PER_PAGE, Github::Constants::PARAM_START_PAGE, Github::Constants::RATELIMIT_LIMIT, Github::Constants::RATELIMIT_REMAINING, Github::Constants::RATELIMIT_RESET, Github::Constants::SERVER, Github::Constants::USER_AGENT
Instance Method Summary collapse
-
#connection(api, options = {}) ⇒ Object
Creates http connection.
-
#default_headers ⇒ Hash[String]
private
Default requets header information.
-
#default_options(options = {}) ⇒ Hash[Symbol]
private
Create default connection options.
-
#stack(options = {}) ⇒ Object
Exposes middleware builder to facilitate custom stacks and easy addition of new extensions such as cache adapter.
Instance Method Details
#connection(api, options = {}) ⇒ Object
Creates http connection
Returns a Fraday::Connection object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/github_api/connection.rb', line 65 def connection(api, = {}) = () .merge!(builder: stack(.merge!(api: api))) if [:connection_options] .deep_merge!([:connection_options]) end if ENV['DEBUG'] p "Connection options : \n" pp end Faraday.new() end |
#default_headers ⇒ Hash[String]
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Default requets header information
22 23 24 25 26 27 28 29 |
# File 'lib/github_api/connection.rb', line 22 def default_headers { ACCEPT => 'application/vnd.github.v3+json,' \ 'application/vnd.github.beta+json;q=0.5,' \ 'application/json;q=0.1', ACCEPT_CHARSET => 'utf-8' } end |
#default_options(options = {}) ⇒ Hash[Symbol]
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create default connection options
37 38 39 40 41 42 43 44 45 |
# File 'lib/github_api/connection.rb', line 37 def ( = {}) headers = default_headers.merge([:headers] || {}) headers.merge!({USER_AGENT => [:user_agent]}) { headers: headers, ssl: [:ssl], url: [:endpoint] } end |
#stack(options = {}) ⇒ Object
Exposes middleware builder to facilitate custom stacks and easy addition of new extensions such as cache adapter.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/github_api/connection.rb', line 51 def stack( = {}) @stack ||= begin builder_class = if defined?(Faraday::RackBuilder) Faraday::RackBuilder else Faraday::Builder end builder_class.new(&Github.default_middleware()) end end |