unfurlers

package
v0.167.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MPL-2.0, MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRequestTimeout = 15000 * time.Millisecond
)

Variables

This section is empty.

Functions

func IsSupportedImageURL

func IsSupportedImageURL(url *neturl.URL) bool

IsSupportedImageURL detects whether a URL ends with one of the supported image extensions. It provides a quick way to identify whether URLs should be unfurled as images without needing to retrieve the full response body first.

Types

type Headers

type Headers map[string]string

type ImageUnfurler

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

func NewImageUnfurler

func NewImageUnfurler(URL *neturl.URL, logger *zap.Logger, httpClient *http.Client) *ImageUnfurler

func (*ImageUnfurler) Unfurl

func (u *ImageUnfurler) Unfurl() (common.LinkPreview, error)

type OEmbedResponse

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

type OEmbedUnfurler

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

func NewOEmbedUnfurler

func NewOEmbedUnfurler(oembedEndpoint string,
	url *neturl.URL,
	logger *zap.Logger,
	httpClient *http.Client) *OEmbedUnfurler

func (OEmbedUnfurler) Unfurl

func (u OEmbedUnfurler) Unfurl() (common.LinkPreview, error)

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).

func NewOpenGraphUnfurler

func NewOpenGraphUnfurler(URL *neturl.URL, logger *zap.Logger, httpClient *http.Client) *OpenGraphUnfurler

func (*OpenGraphUnfurler) Unfurl

func (u *OpenGraphUnfurler) Unfurl() (common.LinkPreview, error)

type Unfurler

type Unfurler interface {
	Unfurl() (common.LinkPreview, error)
}

Jump to

Keyboard shortcuts

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