Share one request, decode, and error path across the client, public endpoints, and export download; align types with the Backend contract and split types_api.go. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
30 lines
702 B
Go
30 lines
702 B
Go
package elydora
|
|
|
|
import "net/http"
|
|
|
|
// Health checks the public health endpoint.
|
|
func Health(baseURL string) (*HealthResponse, error) {
|
|
var result HealthResponse
|
|
if err := publicRequest(http.MethodGet, normalizeBaseURL(baseURL)+"/v1/health", nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// DeepHealth checks backend dependencies; 503 reports a degraded API.
|
|
func DeepHealth(baseURL string) (*DeepHealthResponse, error) {
|
|
var result DeepHealthResponse
|
|
err := publicRequest(
|
|
http.MethodGet,
|
|
normalizeBaseURL(baseURL)+"/v1/health/deep",
|
|
nil,
|
|
&result,
|
|
http.StatusOK,
|
|
http.StatusServiceUnavailable,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|