| GET | /status |
|---|
# frozen_string_literal: true
# encoding: utf-8
require 'json'
require 'servicestack'
module HealthStatus
UNHEALTHY = 'Unhealthy'
DEGRADED = 'Degraded'
HEALTHY = 'Healthy'
end
class HealthCheckReportEntry
include ServiceStack::DTO
# @return [String]
attr_accessor :key
# @return [String]
attr_accessor :description
# @return [Time]
attr_accessor :duration
# @return [HealthStatus]
attr_accessor :status
# @return [String]
attr_accessor :error
def self.properties
{
key: { name: 'key' },
description: { name: 'description' },
duration: { name: 'duration' },
status: { name: 'status' },
error: { name: 'error' },
}
end
end
class HealthCheckReport
include ServiceStack::DTO
# @return [HealthStatus]
attr_accessor :status
# @return [Time]
attr_accessor :duration
# @return [String]
attr_accessor :version
# @return [String]
attr_accessor :build_date
# @return [ICollection]
attr_accessor :entries
def self.properties
{
status: { name: 'status' },
duration: { name: 'duration' },
version: { name: 'version' },
build_date: { name: 'buildDate' },
entries: { name: 'entries', type: [HealthCheckReportEntry] },
}
end
end
class HealthResponse
include ServiceStack::DTO
# @return [HealthCheckReport]
attr_accessor :result
def self.properties
{
result: { name: 'result', type: HealthCheckReport },
}
end
end
class HealthRequest
include ServiceStack::DTO
def response_type() = HealthResponse
def get_type_name() = 'HealthRequest'
end
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /status HTTP/1.1 Host: uat-api-vehicle-mgt-mb-dhc.rapp-customers.co.uk Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
result:
{
status: Unhealthy,
duration: PT0S,
version: String,
buildDate: String
}
}