HttpHealthIndicator

The HTTPHealthIndicator contains health indicators which are used for health checks related to HTTP requests

  
class HttpHealthIndicator {
  pingCheck<Key extends string>(key: Key, url: string, __2: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult<Key>>
  responseCheck<T, Key extends string>(key: Key, url: string | URL, callback: (response: AxiosResponse<T>) => boolean | Promise<boolean>, __3: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult<Key>>
}

Methods

pingCheck()

Checks if the given url response in the given timeout and returns a result object corresponding to the result


pingCheck<Key extends string>(key: Key, url: string, __2: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult<Key>>

Parameters

Option Type Description
key Key

The key which will be used for the result object

url string

The url which should be request

__2 AxiosRequestConfig & { httpClient?: HttpClientLike; }

Optional. Default is {}.

Examples

    
httpHealthIndicator.pingCheck('google', 'https://google.com', { timeout: 800 })

Returns

Promise<HealthIndicatorResult<Key>>

Throws

HealthCheckError In case the health indicator failed

responseCheck()


responseCheck<T, Key extends string>(key: Key, url: string | URL, callback: (response: AxiosResponse<T>) => boolean | Promise<boolean>, __3: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult<Key>>

Parameters

Option Type Description
key Key
url string | URL
callback (response: AxiosResponse) => boolean | Promise
__3 AxiosRequestConfig & { httpClient?: HttpClientLike; }

Optional. Default is {}.

Returns

Promise<HealthIndicatorResult<Key>>