Documentation
¶
Overview ¶
Package favicon discovers, downloads, and decodes website favicons.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownloadResult ¶
type DownloadResult struct {
Icon Icon
URL string
ETag string
LastModified string
// NotModified indicates successful validation; Icon is empty in this case.
NotModified bool
}
DownloadResult describes a downloaded icon and its HTTP cache validators.
func DownloadURL ¶
DownloadURL downloads and decodes an icon from a direct URL.
type Icon ¶
type Icon struct {
// Raster is the decoded image for raster formats.
Raster image.Image
// SVG is the original source for SVG images.
SVG []byte
// Format is the detected format, such as png, ico, or svg.
Format string
// Size is the raster image size and is zero for SVG.
Size image.Point
}
Icon contains either a decoded raster image or the original SVG bytes. Exactly one field is set for a valid icon. SVG bytes are not sanitized.
type Options ¶
type Options struct {
// Client is the HTTP client to use. A nil client uses a five-second timeout.
Client *http.Client
// UserAgent overrides the neutral default User-Agent.
UserAgent string
// ETag and LastModified validate the resource passed to DownloadURL.
// Download discovers an icon and does not use these validators.
ETag string
LastModified string
// Logger is used for diagnostic logging. If nil, logging is disabled.
Logger *slog.Logger
}
Options configures HTTP requests made while discovering or downloading an icon.
func WithLogger ¶ added in v0.2.0
WithLogger returns Options configured with the specified logger.