linkpreview

package
v0.160.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MPL-2.0, MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetURLs

func GetURLs(text string) []string

GetURLs returns only what we consider unfurleable URLs.

If we wanted to be extra precise and help improve UX, we could ignore URLs that we know can't be unfurled. This is at least possible with the oEmbed protocol because providers must specify an endpoint scheme.

func NewDefaultHTTPClient added in v0.154.5

func NewDefaultHTTPClient() http.Client

func UnfurlURLs

func UnfurlURLs(logger *zap.Logger, httpClient http.Client, urls []string) ([]common.LinkPreview, error)

UnfurlURLs assumes clients pass URLs verbatim that were validated and processed by GetURLs.

Types

type Headers added in v0.154.5

type Headers map[string]string

type LinkPreview

type LinkPreview struct {
	common.LinkPreview
}

type OEmbedResponse added in v0.154.5

type OEmbedResponse struct {
	Title        string `json:"title"`
	ThumbnailURL string `json:"thumbnail_url"`
}

type OEmbedUnfurler added in v0.154.5

type OEmbedUnfurler struct {
	// contains filtered or unexported fields
}

type OpenGraphMetadata

type OpenGraphMetadata struct {
	Title        string `json:"title" meta:"og:title"`
	Description  string `json:"description" meta:"og:description"`
	ThumbnailURL string `json:"thumbnailUrl" meta:"og:image"`
}

type OpenGraphUnfurler

type OpenGraphUnfurler struct {
	// contains filtered or unexported fields
}

OpenGraphUnfurler should be preferred over OEmbedUnfurler because oEmbed gives back a JSON response with a "html" field that's supposed to be embedded in an iframe (hardly useful for existing Status' clients).

type Unfurler

type Unfurler interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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