Class: Rx::Check::HttpCheck
- Inherits:
-
Object
- Object
- Rx::Check::HttpCheck
- Defined in:
- lib/rx/check/http_check.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(url, name = "http", timeout: 1) ⇒ HttpCheck
constructor
A new instance of HttpCheck.
Constructor Details
#initialize(url, name = "http", timeout: 1) ⇒ HttpCheck
Returns a new instance of HttpCheck.
8 9 10 11 12 |
# File 'lib/rx/check/http_check.rb', line 8 def initialize(url, name = "http", timeout: 1) @url = URI(url) @name = name @timeout = timeout end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rx/check/http_check.rb', line 6 def name @name end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/rx/check/http_check.rb', line 6 def timeout @timeout end |
Instance Method Details
#check ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rx/check/http_check.rb', line 14 def check Result.from(name) do http = Net::HTTP.new(url.host, url.port) http.read_timeout = timeout http.use_ssl = url.scheme == "https" response = http.request(Net::HTTP::Get.new(path)) response.code == "200" end end |