Class: MoesifApi::HealthController
- Inherits:
-
BaseController
- Object
- BaseController
- MoesifApi::HealthController
- Defined in:
- lib/moesif_api/controllers/health_controller.rb
Constant Summary collapse
- @@instance =
HealthController.new
Instance Attribute Summary
Attributes inherited from BaseController
Class Method Summary collapse
-
.instance ⇒ Object
Singleton instance of the controller class.
Instance Method Summary collapse
-
#get_health_probe ⇒ Object
Health Probe.
Methods inherited from BaseController
#build_request_headers, #initialize, #validate_response
Constructor Details
This class inherits a constructor from MoesifApi::BaseController
Class Method Details
.instance ⇒ Object
Singleton instance of the controller class
7 8 9 |
# File 'lib/moesif_api/controllers/health_controller.rb', line 7 def self.instance @@instance end |
Instance Method Details
#get_health_probe ⇒ Object
Health Probe
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/moesif_api/controllers/health_controller.rb', line 13 def get_health_probe # the base uri for api requests _query_builder = Configuration.base_uri.dup # prepare query string for API call _query_builder << '/health/probe' # validate and preprocess url _query_url = APIHelper.clean_url _query_builder # prepare headers _headers = build_request_headers() # Create the HttpRequest object for the call _request = @http_client.get _query_url, headers: _headers # Call the on_before_request callback @http_call_back.on_before_request(_request) if @http_call_back # Invoke the API call and get the response _response = @http_client.execute_as_string(_request) # Wrap the request and response in an HttpContext object _context = HttpContext.new(_request, _response) # Call the on_after_response callback @http_call_back.on_after_response(_context) if @http_call_back # Global error handling using HTTP status codes. validate_response(_context) # Return appropriate response type decoded = APIHelper.json_deserialize(_response.raw_body) return StatusModel.from_hash(decoded) end |