Documentation
¶
Overview ¶
Package embed provides functionality to fetch and parse metadata from URLs for link previews.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPrivateIP = errors.New("embed: connection to private IP refused") ErrNoAddresses = errors.New("embed: no DNS addresses resolved") ErrTooManyRedirects = errors.New("embed: too many redirects") ErrUnsupportedScheme = errors.New("embed: unsupported scheme") )
View Source
var ErrHTTPStatus = errors.New("unexpected HTTP status")
ErrHTTPStatus is returned when the fetched URL responds with an error status code.
Functions ¶
func RenderRichCard ¶
RenderRichCard returns HTML for a rich card embed.
func RenderVideo ¶
RenderVideo returns HTML for a video embed.
Types ¶
type Client ¶
type Client struct {
HTTPClient *http.Client
MaxEntries int
TTL time.Duration
// contains filtered or unexported fields
}
Client fetches and caches URL metadata for link previews.
type Link ¶
type Link struct {
AuthorName string `json:"author_name,omitempty"`
AuthorURL string `json:"author_url,omitempty"`
CacheAge int `json:"cache_age,omitempty"`
Description string `json:"description,omitempty"`
Height int `json:"height,omitempty"`
HTML string `json:"html,omitempty"`
ProviderName string `json:"provider_name,omitempty"`
ProviderURL string `json:"provider_url,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
Title string `json:"title,omitempty"`
Type string `json:"type"`
URL string `json:"url"`
Width int `json:"width,omitempty"`
}
Link holds metadata extracted from a URL, matching the LinkEmbedder JSON format.
Click to show internal directories.
Click to hide internal directories.