Module: RestClientWrapper::Http
- Included in:
- RestClient
- Defined in:
- lib/rest_client_wrapper/http.rb
Overview
Http
Constant Summary collapse
- SUCCESS_STATUS_CODES =
{ 200 => "OK", 201 => "Created", 202 => "Accepted", 203 => "Non-Authoritative Information", 205 => "No Content", 206 => "Partial Content", 207 => "Multi-Status" }.freeze
Class Method Summary collapse
-
.bad_request?(code) ⇒ Boolean
400.
-
.not_found?(code) ⇒ Boolean
404.
-
.ok?(code) ⇒ Boolean
200.
-
.success?(code) ⇒ Boolean
success.
-
.too_many_requests?(code) ⇒ Boolean
429.
-
.unauthorized?(code) ⇒ Boolean
401.
Class Method Details
.bad_request?(code) ⇒ Boolean
400
45 46 47 |
# File 'lib/rest_client_wrapper/http.rb', line 45 def self.bad_request?(code) return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:bad_request] end |
.not_found?(code) ⇒ Boolean
404
55 56 57 |
# File 'lib/rest_client_wrapper/http.rb', line 55 def self.not_found?(code) return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:not_found] end |
.ok?(code) ⇒ Boolean
200
40 41 42 |
# File 'lib/rest_client_wrapper/http.rb', line 40 def self.ok?(code) return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:ok] end |
.success?(code) ⇒ Boolean
success
35 36 37 |
# File 'lib/rest_client_wrapper/http.rb', line 35 def self.success?(code) return !SUCCESS_STATUS_CODES[code].nil? end |
.too_many_requests?(code) ⇒ Boolean
429
60 61 62 |
# File 'lib/rest_client_wrapper/http.rb', line 60 def self.too_many_requests?(code) return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:too_many_requests] end |
.unauthorized?(code) ⇒ Boolean
401
50 51 52 |
# File 'lib/rest_client_wrapper/http.rb', line 50 def self.(code) return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:unauthorized] end |