Class: Imperium::Response
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Imperium::Response
- Defined in:
- lib/imperium/response.rb
Overview
A Response is a decorator around the HTTP::Message object returned when a request is made.
It exposes, through a convenient API, headers common to all interactions with the Consul HTTP API
Direct Known Subclasses
Instance Method Summary collapse
-
#known_leader? ⇒ TrueClass, ...
Indicates if the contacted server has a known leader.
-
#last_contact ⇒ NilClass, Integer
The time in miliseconds since the contacted server has been in contact with the leader.
-
#not_found? ⇒ Boolean
A convenience method for checking if the response had a 404 status code.
-
#translate_addresses? ⇒ TrueClass, FalseClass
Indicate status of translate_wan_addrs setting on the server.
Instance Method Details
#known_leader? ⇒ TrueClass, ...
Indicates if the contacted server has a known leader.
16 17 18 19 |
# File 'lib/imperium/response.rb', line 16 def known_leader? return unless headers.key?('X-Consul-KnownLeader') headers['X-Consul-KnownLeader'] == 'true' end |
#last_contact ⇒ NilClass, Integer
The time in miliseconds since the contacted server has been in contact with the leader.
26 27 28 29 |
# File 'lib/imperium/response.rb', line 26 def last_contact return unless headers.key?('X-Consul-LastContact') Integer(headers['X-Consul-LastContact']) end |
#not_found? ⇒ Boolean
A convenience method for checking if the response had a 404 status code.
32 33 34 |
# File 'lib/imperium/response.rb', line 32 def not_found? status == 404 end |
#translate_addresses? ⇒ TrueClass, FalseClass
Indicate status of translate_wan_addrs setting on the server.
40 41 42 |
# File 'lib/imperium/response.rb', line 40 def translate_addresses? headers.key?('X-Consul-Translate-Addresses') end |