Documentation
¶
Overview ¶
Package sunrisesunset is the library behind the sunrisesunset command line: the HTTP client, request shaping, and the typed data models for the sunrise-sunset.org API (sunrise/sunset/twilight times for any location).
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 Host = "api.sunrise-sunset.org"
Host is the API hostname this package talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to api.sunrise-sunset.org over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tuneable parameters for a Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the production configuration for api.sunrise-sunset.org.
type Domain ¶
type Domain struct{}
Domain is the sunrisesunset 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.
type SunTimes ¶
type SunTimes struct {
Location string `json:"location" kit:"id"` // "lat,lon" formatted as "%.4f,%.4f"
Date string `json:"date"`
Timezone string `json:"timezone"`
Sunrise string `json:"sunrise"`
Sunset string `json:"sunset"`
SolarNoon string `json:"solar_noon"`
DayLengthSeconds int `json:"day_length_seconds"`
CivilTwilightBegin string `json:"civil_twilight_begin"`
CivilTwilightEnd string `json:"civil_twilight_end"`
NauticalTwilightBegin string `json:"nautical_twilight_begin"`
NauticalTwilightEnd string `json:"nautical_twilight_end"`
AstronomicalTwilightBegin string `json:"astronomical_twilight_begin"`
AstronomicalTwilightEnd string `json:"astronomical_twilight_end"`
}
SunTimes holds the full set of times returned by the API for one query.