types

package
v0.0.0-...-6d5114b Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 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, MimeTypesJSONFeed)
	// 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"}
)
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",
}

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 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 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 struct {
	Value xml.CharData `json:"CharData"`
}

CharData represents character data of an element.

func (*CharData) String

func (c *CharData) String() string

func (*CharData) UnmarshalJSON

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

func (*CharData) UnmarshalText

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

type CustomTypeBase

type CustomTypeBase struct {
	// Attributes are any attributes of the element.
	Attributes Attributes `json:"attributes" xml:",any,attr"`

	// Value is an element value that is required.
	Value RequiredValue `json:"value" validate:"required" xml:",chardata"`
}

CustomTypeBase defines model for CustomTypeBase.

func (*CustomTypeBase) String

func (c *CustomTypeBase) String() string

String will return the value of the object.

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) 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 XMLName `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" 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
	GetItems() []ItemSource
}

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"`

	// 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. Language codes possible are detailed in RFC 3066.

type MediaEditable

type MediaEditable interface {
	SetImage(image *ImageInfo)
}

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

type NameSpace

type NameSpace string

NameSpace maps namespace URL identifiers to a easy-to-use string type.

const (
	NameSpaceAtom        NameSpace = "http://www.w3.org/2005/Atom"
	NameSpaceContent     NameSpace = "http://purl.org/rss/1.0/modules/content/"
	NameSpaceDublinCore  NameSpace = "http://purl.org/dc/elements/1.1/"
	NameSpaceMediaRSS    NameSpace = "http://search.yahoo.com/mrss/"
	NameSpaceSyndication NameSpace = "http://purl.org/rss/1.0/modules/syndication/"
)

Defines values for NameSpace.

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 StringData

type StringData string

func (*StringData) String

func (s *StringData) String() string

func (*StringData) UnmarshalText

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

type URL

type URL = string

URL is a URL link.

type XMLName

type XMLName = xml.Name

XMLName represents the XML namespace of an element.

Jump to

Keyboard shortcuts

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