Documentation
¶
Overview ¶
Package spaceflight is the library behind the spaceflight command line: the HTTP client, request shaping, and the typed data models for the Spaceflight News API (https://api.spaceflightnewsapi.net/v4).
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.
Index ¶
- Constants
- type Article
- type Client
- func (c *Client) Article(ctx context.Context, id string) (*Article, error)
- func (c *Client) Articles(ctx context.Context, opts ListOptions) ([]*Article, error)
- func (c *Client) Blogs(ctx context.Context, opts ListOptions) ([]*Article, error)
- func (c *Client) Reports(ctx context.Context, opts ListOptions) ([]*Article, error)
- type Config
- type Domain
- type ListOptions
Constants ¶
const Host = "spaceflightnewsapi.net"
Host is the canonical hostname used in URI classification.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
ID int `json:"id"`
Title string `json:"title"`
URL string `json:"url"`
ImageURL string `json:"image_url,omitempty"`
NewsSite string `json:"news_site,omitempty"`
Summary string `json:"summary,omitempty"`
PublishedAt string `json:"published_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Featured bool `json:"featured,omitempty"`
}
Article represents a single news article from the Spaceflight News API. Reports and blogs share the same structure.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Spaceflight News API over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds the tunable knobs for a Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the Spaceflight News API.
type Domain ¶
type Domain struct{}
Domain is the spaceflight 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.
type ListOptions ¶
ListOptions controls which articles/reports/blogs are returned by a list call.