Documentation
¶
Overview ¶
Package openligadb is the library behind the openligadb command line: the HTTP client, request shaping, and the typed data models for the OpenLigaDB API (German football statistics).
The Client 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.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "openligadb-cli/0.1.0 (github.com/tamnd/openligadb-cli)"
DefaultUserAgent identifies the client to OpenLigaDB.
const Host = "api.openligadb.de"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
BaseURL string
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to OpenLigaDB over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from cfg.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the client.
type Domain ¶
type Domain struct{}
Domain is the OpenLigaDB driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type League ¶
type League struct {
ID int `json:"leagueId"`
Name string `json:"leagueName"`
Shortcut string `json:"leagueShortcut"`
Season string `json:"leagueSeason"`
}
League represents an available league in OpenLigaDB.
type Match ¶
type Match struct {
ID int `json:"match_id"`
DateTime string `json:"match_datetime"`
Home string `json:"home_team"`
Away string `json:"away_team"`
Group string `json:"group"`
ScoreHalf string `json:"score_halftime,omitempty"`
ScoreFinal string `json:"score_final,omitempty"`
Finished bool `json:"finished"`
}
Match is the flattened match record we emit.