Documentation
¶
Overview ¶
Package openlibrary is the library behind the openlibrary command line: the HTTP client, request shaping, and the typed data models for openlibrary.
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 site throws under load.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "Mozilla/5.0 (compatible; openlibrary-cli/dev; +https://github.com/tamnd/openlibrary-cli)"
DefaultUserAgent identifies the client to Open Library.
const Host = "openlibrary.org"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
Rank int `json:"rank" csv:"rank" tsv:"rank"`
Key string `json:"key" csv:"key" tsv:"key"`
Title string `json:"title" csv:"title" tsv:"title"`
Authors []string `json:"authors" csv:"authors" tsv:"authors"`
FirstYear int `json:"first_publish_year" csv:"first_publish_year" tsv:"first_publish_year"`
Editions int `json:"edition_count" csv:"edition_count" tsv:"edition_count"`
EbookAccess string `json:"ebook_access" csv:"ebook_access" tsv:"ebook_access"`
Languages []string `json:"languages" csv:"languages" tsv:"languages"`
CoverID int `json:"cover_id" csv:"cover_id" tsv:"cover_id"`
URL string `json:"url" csv:"url" tsv:"url"`
}
Book is one book record from Open Library.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to Open Library over HTTP.
func (*Client) SearchBooks ¶
SearchBooks searches Open Library for books matching query.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable client parameters.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for a polite CLI client.
type Domain ¶
type Domain struct{}
Domain is the openlibrary driver. It carries no state; the per-run client is built by the factory Register hands kit.
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.