types

package
v0.0.0-...-e4207ad Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package types 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.

Package types 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.

Package types 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.

Package types contains methods and objects that are shared across different Feed schemas/specifications.

Index

Constants

View Source
const (
	// MimeTypeOPML indicates the canonical mimetype for an OPML file.
	MimeTypeOPML = "text/x-opml+xml"
)

Variables

View Source
var (
	// MimeTypesRSS contains canonical/standard mimetypes for RSS feeds.
	MimeTypesRSS = []string{"application/rss+xml", "application/rdf+xml"}
	// MimeTypesAtom contains canonical/standard mimetypes for Atom feeds.
	MimeTypesAtom = []string{"application/atom+xml"}
	// MimeTypesIndeterminate contains mimetypes that can be used for either RSS/Atom feeds and don't give any clues to
	// the actual type.
	MimeTypesIndeterminate = []string{"application/xml", "text/xml"}
	// MimeTypesJSONFeed contains canonical/standard mimetypes for JSONFeed feeds.
	MimeTypesJSONFeed = []string{"application/feed+json", "application/json"}
	// MimeTypesFeed is the concatenation of all feed mime types.
	MimeTypesFeed = slices.Concat(MimeTypesAtom, MimeTypesRSS, MimeTypesIndeterminate)
	// MimeTypesHTML contains canonical/standard mimetypes for HTML.
	MimeTypesHTML = []string{"text/html", "application/xhtml+xml"}
	// MimeTypesImage contains canonical/standard/common mimetypes for images.
	MimeTypesImage = []string{"image/avif", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/webp"}
	// MediaImageExt contains canonical/standard/common file extensions for images.
	MediaImageExt = []string{"jpg", "jpeg", "png", "webp", "gif"}
)
View Source
var DateTimeFormats = []string{
	time.RFC1123Z,
	time.RFC1123,
	"Mon, 2 Jan 2006 15:04:05 -0700",
	"Mon, 2 Jan 2006 15:04:05 MST",
	"Mon, 02 Jan 2006 15:04 -0700",
	"Mon, 02 Jan 2006 15:04 MST",
	"Mon, 2 Jan 2006 15:04 -0700",
	"Mon, 2 Jan 2006 15:04 MST",
	time.RFC3339,
	"2006-01-02T15:04:05.00Z07:00",
	time.DateTime,
	time.DateOnly,
	time.DateOnly + "T" + "15:04-07:00",
	"2006-01",
	"2006",
	"Jan 2, 2006",
	"2006 Jan 2 15:04:05 MST",
	"Mon, 2 Jan 2006",
}

DateTimeFormats are the valid datetime formats across different feed specifications. A DateTime object will try to parse a given value as one of these formats.

View Source
var (
	// DefaultFeedUpdateInterval defines the update interval for feeds that do not define an update interval or where
	// one cannot be calculated based off item frequency.
	DefaultFeedUpdateInterval = time.Hour
)
View Source
var ErrInvalidDateTimeFormat = errors.New("invalid datetime format")

ErrInvalidDateTimeFormat indicates that the value of the datetime is not one of the defined DateTimeFormats. In most cases, this indicates the feed not using a valid datetime format according to its specification.

View Source
var UnixEpoch = time.Unix(0, 0)

UnixEpoch is the time.Time value of Unix epoch.

Functions

func GetMedianInterval

func GetMedianInterval(data []time.Duration) time.Duration

func IsImage

func IsImage(mimetype string) bool

IsImage will return a boolean indicating whether the given mimetype represents an image.

func NewXMLAttr

func NewXMLAttr(name, value, namespace string) xml.Attr

NewXMLAttr is a convienience function to create an xml.Attr from a name/value/namespace combination. The namespace value is optional, but the name and value should be provided.

Types

type AttrBitrate

type AttrBitrate = int

AttrBitrate is the kilobits per second rate of media.

type AttrChannels

type AttrChannels = int

AttrChannels is number of audio channels in the media object.

type AttrDuration

type AttrDuration = int

AttrDuration is the number of seconds the media object plays.

type AttrFileSize

type AttrFileSize = int

AttrFileSize is the number of bytes of the media object.

type AttrFramerate

type AttrFramerate = int

AttrFramerate is the number of frames per second for the media object.

type AttrHeight

type AttrHeight = int

AttrHeight is the height of the media object.

type AttrHref

type AttrHref = string

AttrHref is a URL that represents the element content.

type AttrLang

type AttrLang = string

AttrLang is the primary language encapsulated in the element. Language codes possible are detailed in RFC 3066. This attribute is used similar to the xml:lang attribute detailed in the XML 1.0 Specification (Third Edition).

type AttrMimeType

type AttrMimeType = string

AttrMimeType is the standard MIME type of the object.

type AttrSamplingrate

type AttrSamplingrate = int

AttrSamplingrate is the number of samples per second taken to create the media object. It is expressed in thousands of samples per second (kHz)

type AttrURL

type AttrURL = string

AttrURL is a URL that represents the element content.

type AttrWidth

type AttrWidth = int

AttrWidth is the width of the media object. It is an optional attribute.

type Attributes

type Attributes = []xml.Attr

Attributes are any attributes of the element.

type CharData

type CharData xml.CharData

CharData is a custom type for xml.CharData that can additionally sanitize the data.

func (*CharData) String

func (c *CharData) String() string

func (*CharData) UnmarshalJSON

func (c *CharData) UnmarshalJSON(data []byte) error

UnmarshalJSON provides custom unmarshaling of CharData that will sanitize, unescape and trim whitespace from the value.

func (*CharData) UnmarshalText

func (c *CharData) UnmarshalText(data []byte) error

UnmarshalText provides custom unmarshaling of CharData that will sanitize, unescape and trim whitespace from the value.

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a datetime value for a feed (or item) object, such as its published/updated date.

func (*DateTime) MarshalJSON

func (d *DateTime) MarshalJSON() ([]byte, error)

MarshalJSON handles marshaling a DateTime to JSON.

func (*DateTime) MarshalText

func (d *DateTime) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. Serializes DateTime to a plain byte slice. Uses RFC822 for widest compatibility.

func (*DateTime) String

func (d *DateTime) String() string

String returns a string representation of the DateTime.

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON handles unmarshaling a DateTime from JSON.

func (*DateTime) UnmarshalText

func (d *DateTime) UnmarshalText(data []byte) error

UnmarshalText will unmarshal/parse a DateTime from the given string.

func (*DateTime) Valid

func (d *DateTime) Valid() (bool, error)

Valid will determine whether the value of the DateTime is valid. That is, is not the zero value or equal to the Unix Epoch.

type Extension

type Extension struct {
	// XMLName represents the XML namespace of an element.
	XMLName xml.Name `json:"xml" validate:"required"`

	// Attributes are any attributes of the element.
	Attributes Attributes  `json:"attributes" xml:",any,attr"`
	Extensions []Extension `json:"extensions,omitempty" xml:",any"`

	// Value is an element value that is optional.
	Value OptionalValue `json:"value,omitempty,omitzero" xml:",chardata"`
}

Extension represents an element that is not defined in the schema.

type Extensions

type Extensions = []Extension

Extensions records any elements that are unknown extensions to the schema.

type FeedSource

type FeedSource interface {
	ObjectCommon
	Source
	SourceEditable
	MediaEditable
	GetUpdateInterval() time.Duration
	GetItems() []ItemSource
	Validate() error
}

FeedSource is an abstraction representing any type of Feed.

type HasAttribution

type HasAttribution interface {
	GetAuthors() []string
	GetContributors() []string
	GetRights() *string
}

HasAttribution contains methods for retrieving values that relate to the copyright, rights, authors and contributors of an Object.

type HasContent

type HasContent interface {
	GetContent() *string
}

HasContent contains methods for retrieving any embedded content of the Object.

type HasID

type HasID interface {
	GetID() string
}

HasID contains methods for retrieving an Objects unique ID.

type HasLocalization

type HasLocalization interface {
	GetLanguage() *string
}

HasLocalization contains methods for retrieving localization information of an Object.

type HasMedia

type HasMedia interface {
	GetImage() *ImageInfo
}

HasMedia contains methods for retrieving an Object's media, such as audio and video.

type HasTaxonomy

type HasTaxonomy interface {
	GetCategories() []string
}

HasTaxonomy contains methods for retrieving categorization and taxonomy values of an Object.

type ImageInfo

type ImageInfo struct {
	// Title the description of the image
	Title string `json:"title,omitempty,omitzero"`

	// URL is the URL to the image.
	URL string `json:"url" validate:"required,url" xml:",chardata"`
}

ImageInfo is an abstraction of an Image across different types of specifications.

func (*ImageInfo) GetTitle

func (i *ImageInfo) GetTitle() string

GetTitle returns the title (if any) of the image.

func (*ImageInfo) GetURL

func (i *ImageInfo) GetURL() string

GetURL returns the URL of the image.

type ItemSource

type ItemSource interface {
	ObjectCommon
	HasID
	HasContent
}

ItemSource is an abstraction representing an individual Item from any type of Feed source.

type Language

type Language = string

Language is the primary language encapsulated in the element.

type MediaEditable

type MediaEditable interface {
	SetImage(image *ImageInfo)
}

MediaEditable indicates that the media of the object can be changed.

type ObjectCommon

ObjectCommon contains all methods common across all objects.

type ObjectMetadata

type ObjectMetadata interface {
	GetTitle() string
	GetDescription() string
	GetLink() string
	GetPublishedDate() *time.Time
	GetUpdatedDate() *time.Time
}

ObjectMetadata contains methods for retrieving the metadata information about the Object.

type OptionalValue

type OptionalValue = string

OptionalValue is an element value that is optional.

type RequiredValue

type RequiredValue = string

RequiredValue is an element value that is required.

type Source

type Source interface {
	GetSourceURL() string
}

Source contains methods for retrieving or setting the source of the Object.

type SourceEditable

type SourceEditable interface {
	SetSourceURL(url string)
}

SourceEditable indicates the source URL for the object can be changed.

type SourceType

type SourceType string

SourceType is the type of source the feed or object came from. This can be used with abstractions that generalize different feed types into a common format to preserve information on the original.

const (
	SourceTypeAtom     SourceType = "Atom"
	SourceTypeHTML     SourceType = "HTML"
	SourceTypeJSONFeed SourceType = "JSONFeed"
	SourceTypeRDF      SourceType = "RDF"
	SourceTypeRSS      SourceType = "RSS"
	SourceTypeUnknown  SourceType = "Unknown"
)

Defines values for SourceType.

type String

type String string

String is custom string type that handles "malformed" string fields containing whitespace or forbidden input.

func (String) String

func (s String) String() string

func (*String) UnmarshalText

func (s *String) UnmarshalText(data []byte) error

UnmarshalText provides custom unmarshaling of String that will sanitize, unescape and trim whitespace from the value.

type URL

type URL = string

URL is a URL link.

Jump to

Keyboard shortcuts

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