Class: KeycloakApiRails::HTTPClient
- Inherits:
-
Object
- Object
- KeycloakApiRails::HTTPClient
- Defined in:
- lib/keycloak-api-rails/http_client.rb
Constant Summary collapse
- UNREACHABLE_ERRORS =
[ Timeout::Error, SocketError, SystemCallError, IOError, OpenSSL::SSL::SSLError, Net::ProtocolError ].freeze
Instance Method Summary collapse
- #get(realm_id, path) ⇒ Object
-
#initialize(configuration, logger) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
Constructor Details
#initialize(configuration, logger) ⇒ HTTPClient
Returns a new instance of HTTPClient.
21 22 23 24 25 26 27 |
# File 'lib/keycloak-api-rails/http_client.rb', line 21 def initialize(configuration, logger) @configuration = configuration @logger = logger @x509_store = OpenSSL::X509::Store.new @x509_store.set_default_paths @x509_store.add_file(configuration.ca_certificate_file) if configuration.ca_certificate_file end |
Instance Method Details
#get(realm_id, path) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/keycloak-api-rails/http_client.rb', line 29 def get(realm_id, path) @configuration.validate_server! uri = build_uri(realm_id, path) response = request(uri) unless response.is_a?(Net::HTTPSuccess) @logger.error("KeycloakApiRails: Keycloak responded with an error when calling '#{path}'. Status #{response.code}. Payload: #{response.body}") raise HTTPError.new("Keycloak responded with a #{response.code} status when calling '#{path}'", response.code) end parse(response, path) end |