go-client/health.go
Deivid Soto f6f24c2c3f
Some checks failed
CI / Test (push) Failing after 1s
CI / Test-1 (push) Failing after 1s
CI / Test-2 (push) Failing after 1s
CI / Lint (push) Failing after 1s
CI / Vet (push) Failing after 1s
feat: implement TorrentClaw Go API client v0.1.0
2026-03-28 11:28:48 +01:00

58 lines
1.7 KiB
Go

package torrentclaw
import "context"
// HealthResponse contains the API health status.
type HealthResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Uptime int `json:"uptime"`
Database *string `json:"database,omitempty"`
Redis *string `json:"redis,omitempty"`
}
// MirrorInfo represents an active TorrentClaw mirror instance.
type MirrorInfo struct {
URL string `json:"url"`
Label string `json:"label"`
Primary bool `json:"primary"`
}
// TorInfo represents a Tor (.onion) access point.
type TorInfo struct {
URL string `json:"url"`
Label string `json:"label"`
}
// StatusChannel represents a status/announcement channel.
type StatusChannel struct {
Label string `json:"label"`
URL string `json:"url"`
}
// MirrorsResponse contains the list of mirrors and access channels.
type MirrorsResponse struct {
Mirrors []MirrorInfo `json:"mirrors"`
Tor *TorInfo `json:"tor,omitempty"`
Lite *string `json:"lite,omitempty"`
Channels []StatusChannel `json:"channels,omitempty"`
}
// Health returns the API health status. This endpoint does not require authentication.
func (c *Client) Health(ctx context.Context) (*HealthResponse, error) {
var resp HealthResponse
if err := c.doJSON(ctx, "/api/health", nil, &resp); err != nil {
return nil, err
}
return &resp, nil
}
// Mirrors returns the list of active TorrentClaw mirrors and access channels.
// This endpoint does not require authentication.
func (c *Client) Mirrors(ctx context.Context) (*MirrorsResponse, error) {
var resp MirrorsResponse
if err := c.doJSON(ctx, "/api/mirrors", nil, &resp); err != nil {
return nil, err
}
return &resp, nil
}