Documentation
¶
Overview ¶
Package whogho is the library behind the whogho command line: the HTTP client, request shaping, and the typed data models for the WHO Global Health Observatory (GHO) OData API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Build your endpoint calls and JSON decoding on top of it.
Index ¶
Constants ¶
const Host = "ghoapi.azureedge.net"
Host is the base hostname for the WHO GHO OData API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the WHO GHO OData API over HTTP.
func (*Client) GetData ¶
func (c *Client) GetData(ctx context.Context, indicatorCode, country string, year int, dim1 string, limit int) ([]DataPoint, error)
GetData retrieves data points for a given indicator, optionally filtering by country code, year, Dim1 value, and limiting the number of results.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tuneable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible production defaults.
type Country ¶
type Country struct {
Code string `json:"code"`
Name string `json:"name"`
Region string `json:"region,omitempty"`
}
Country is a WHO GHO country (spatial dimension) value.
type DataPoint ¶
type DataPoint struct {
Indicator string `json:"indicator"`
Country string `json:"country,omitempty"` // SpatialDim
Year int `json:"year,omitempty"` // TimeDim
Value *float64 `json:"value"` // NumericValue, nil if missing
Low *float64 `json:"low,omitempty"`
High *float64 `json:"high,omitempty"`
Dimension1 string `json:"dimension1,omitempty"` // Dim1 (e.g. SEX_BTSX)
Comments string `json:"comments,omitempty"`
}
DataPoint is a single observation from the WHO GHO data.
type Domain ¶
type Domain struct{}
Domain is the whogho driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.