opengraph

package
v0.0.0-...-766a4ab Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package opengraph provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio = string

Audio is a URL to an audio file to accompany this object.

type Description

type Description = string

Description is a one to two sentence description of your object.

type Image

type Image = string

Image is an image URL which should represent your object within the graph.

type Locale

type Locale = string

Locale is the locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.

type ObjectType

type ObjectType = string

ObjectType is the type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.

type OpenGraph

type OpenGraph struct {
	// Audio is a URL to an audio file to accompany this object.
	Audio *Audio `json:"audio,omitempty" validate:"omitempty,url"`

	// Description is a one to two sentence description of your object.
	Description *Description `json:"description,omitempty"`

	// Image is an image URL which should represent your object within the graph.
	Image Image `json:"image" validate:"required,url"`

	// Locale is the locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
	Locale *Locale `json:"locale,omitempty"`

	// ObjectType is the type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
	ObjectType ObjectType `json:"object_type" validate:"required"`

	// SiteName is a value that when your object is part of a larger web site, the name which should be displayed for the overall site.
	SiteName *SiteName `json:"site_name,omitempty"`

	// Title is title of your object as it should appear within the graph, e.g., "The Rock".
	Title Title `json:"title" validate:"required"`

	// URL is the canonical URL of your object that will be used as its permanent ID in the graph, e.g., "https://www.imdb.com/title/tt0117500/".
	URL URL `json:"url" validate:"required,url"`

	// Video is a URL to a video file to accompany this object.
	Video                *Video            `json:"video,omitempty" validate:"omitempty,url"`
	AdditionalProperties map[string]string `json:"-"`
}

OpenGraph is an object containing all opengraph metadata.

func New

func New(title Title, objectType ObjectType, url URL, image Image, options ...Option) *OpenGraph

New creates a new open graph object with the given required values and any additional values as options.

func ParseBytes

func ParseBytes(data []byte, options ...ParseOption) (*OpenGraph, error)

ParseBytes will parse the given byte array and return any Open Graph metadata found within. Use with existing HTML page data.

func (OpenGraph) Get

func (a OpenGraph) Get(fieldName string) (value string, found bool)

Getter for additional properties for OpenGraph. Returns the specified element and whether it was found

func (OpenGraph) MarshalJSON

func (a OpenGraph) MarshalJSON() ([]byte, error)

Override default JSON handling for OpenGraph to handle AdditionalProperties

func (*OpenGraph) Set

func (a *OpenGraph) Set(fieldName string, value string)

Setter for additional properties for OpenGraph

func (*OpenGraph) String

func (og *OpenGraph) String() string

func (*OpenGraph) UnmarshalJSON

func (a *OpenGraph) UnmarshalJSON(b []byte) error

Override default JSON handling for OpenGraph to handle AdditionalProperties

func (*OpenGraph) UnmarshalXML

func (og *OpenGraph) UnmarshalXML(d *xml.Decoder, se xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler. It scans all <meta> elements anywhere in the document and populates OGMeta fields from those whose property/name attribute starts with "og:".

func (*OpenGraph) Valid

func (og *OpenGraph) Valid() error

type Option

type Option func(*OpenGraph)

func WithAdditionalProperty

func WithAdditionalProperty(key, value string) Option

func WithAudio

func WithAudio(audio Audio) Option

func WithDescription

func WithDescription(desc Description) Option

func WithLocale

func WithLocale(locale Locale) Option

func WithSiteName

func WithSiteName(name SiteName) Option

func WithVideo

func WithVideo(video Video) Option

type ParseOption

type ParseOption func(*parseOptions)

ParseOption is a functional option to apply to an Open Graph parsing method.

func WithClient

func WithClient(c *resty.Client) ParseOption

WithClient option specifies an existing http client to use for parsing remote content.

type SiteName

type SiteName = string

SiteName is a value that when your object is part of a larger web site, the name which should be displayed for the overall site.

type Title

type Title = string

Title is title of your object as it should appear within the graph, e.g., "The Rock".

type URL

type URL = string

URL is the canonical URL of your object that will be used as its permanent ID in the graph, e.g., "https://www.imdb.com/title/tt0117500/".

type Video

type Video = string

Video is a URL to a video file to accompany this object.

Jump to

Keyboard shortcuts

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