Documentation
¶
Overview ¶
Package adviceslip is the library behind the adviceslip command line: the HTTP client, request shaping, and typed data models for api.adviceslip.com.
The Client sets a real User-Agent, paces requests, and retries transient failures (429 and 5xx) with exponential backoff. Two operations are provided: get a random advice slip and search for slips by keyword.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const Host = "api.adviceslip.com"
Host is the site this client 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.adviceslip.com over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds tunable knobs for the HTTP client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for production use.
type Domain ¶
type Domain struct{}
Domain is the adviceslip kit driver. It carries no state; the per-run client is built by the factory Register hands to kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and the identity used in help and version.