Module: Hackeroo::Default
- Defined in:
- lib/hackeroo/default.rb
Constant Summary collapse
- ENDPOINT =
'http://api.hackeroo.io'
- CONNECTION_OPTIONS =
{ :headers => { :accept => 'application/json', :user_agent => "Hackeroo Ruby Gem #{Hackeroo::Version}", }, :request => { :open_timeout => 5, :timeout => 10, }, }
- IDENTITY_MAP =
false
- MIDDLEWARE =
Faraday::Builder.new do |builder| # Convert request params to "www-form-urlencoded" builder.use Faraday::Request::UrlEncoded # Handle 4xx server responses builder.use Hackeroo::Response::RaiseError, Hackeroo::Error::ClientError # Parse JSON response bodies using MultiJson builder.use Hackeroo::Response::ParseJson # Handle 5xx server responses builder.use Hackeroo::Response::RaiseError, Hackeroo::Error::ServerError # Set Faraday's HTTP adapter builder.adapter Faraday.default_adapter end
Class Method Summary collapse
- .clientkey ⇒ String
- .connection_options ⇒ Object
- .endpoint ⇒ String
- .identity_map ⇒ Object
- .middleware ⇒ Faraday::Builder
- .options ⇒ Hash
Class Method Details
.clientkey ⇒ String
45 46 47 |
# File 'lib/hackeroo/default.rb', line 45 def clientkey ENV['HACKEROO_CLIENTKEY'] end |
.connection_options ⇒ Object
59 60 61 |
# File 'lib/hackeroo/default.rb', line 59 def CONNECTION_OPTIONS end |
.endpoint ⇒ String
Note:
This is configurable in case you want to use a Hackeroo-compatible endpoint.
55 56 57 |
# File 'lib/hackeroo/default.rb', line 55 def endpoint ENDPOINT end |
.identity_map ⇒ Object
63 64 65 |
# File 'lib/hackeroo/default.rb', line 63 def identity_map IDENTITY_MAP end |
.middleware ⇒ Faraday::Builder
Note:
Faraday’s middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.
71 72 73 |
# File 'lib/hackeroo/default.rb', line 71 def middleware MIDDLEWARE end |
.options ⇒ Hash
40 41 42 |
# File 'lib/hackeroo/default.rb', line 40 def Hash[Hackeroo::Configurable.keys.map{|key| [key, send(key)]}] end |