faviconcache

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFavicon

func GetFavicon(urlStr string) string

--- GetFavicon ---

GetFavicon takes a URL string and returns a base64-encoded src URL for an <img> tag. If the favicon is already in cache and “fresh,” it returns it immediately. Otherwise it kicks off a background fetch (if one isn’t already in progress) and returns whatever is in the cache (which may be empty).

func SetInCache

func SetInCache(key string, item FaviconCacheItem)

Types

type FaviconCacheItem

type FaviconCacheItem struct {
	// Data is the base64-encoded data URL string (e.g. "data:image/png;base64,...")
	Data string
	// LastFetched is when this entry was last updated.
	LastFetched time.Time
}

FaviconCacheItem represents one cached favicon entry.

func GetFromCache

func GetFromCache(key string) (FaviconCacheItem, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL