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
- Variables
- func GetMedianInterval(data []time.Duration) time.Duration
- func IsImage(mimetype string) bool
- func NewXMLAttr(name, value, namespace string) xml.Attr
- type AttrBitrate
- type AttrChannels
- type AttrDuration
- type AttrFileSize
- type AttrFramerate
- type AttrHeight
- type AttrHref
- type AttrLang
- type AttrMimeType
- type AttrSamplingrate
- type AttrURL
- type AttrWidth
- type Attributes
- type CharData
- type DateTime
- type Extension
- type Extensions
- type FeedSource
- type HasAttribution
- type HasContent
- type HasID
- type HasLocalization
- type HasMedia
- type HasTaxonomy
- type ImageInfo
- type ItemSource
- type Language
- type MediaEditable
- type ObjectCommon
- type ObjectMetadata
- type OptionalValue
- type RequiredValue
- type Source
- type SourceEditable
- type SourceType
- type String
- type URL
Constants ¶
const (
// MimeTypeOPML indicates the canonical mimetype for an OPML file.
MimeTypeOPML = "text/x-opml+xml"
)
Variables ¶
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"} )
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.
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 )
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.
var UnixEpoch = time.Unix(0, 0)
UnixEpoch is the time.Time value of Unix epoch.
Functions ¶
func IsImage ¶
IsImage will return a boolean indicating whether the given mimetype represents an image.
func NewXMLAttr ¶
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 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 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 AttrWidth ¶
type AttrWidth = int
AttrWidth is the width of the media object. It is an optional attribute.
type CharData ¶
CharData is a custom type for xml.CharData that can additionally sanitize the data.
func (*CharData) UnmarshalJSON ¶
UnmarshalJSON provides custom unmarshaling of CharData that will sanitize, unescape and trim whitespace from the value.
func (*CharData) UnmarshalText ¶
UnmarshalText provides custom unmarshaling of CharData that will sanitize, unescape and trim whitespace from the value.
type DateTime ¶
DateTime is a datetime value for a feed (or item) object, such as its published/updated date.
func (*DateTime) MarshalJSON ¶
MarshalJSON handles marshaling a DateTime to JSON.
func (*DateTime) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. Serializes DateTime to a plain byte slice. Uses RFC822 for widest compatibility.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON handles unmarshaling a DateTime from JSON.
func (*DateTime) UnmarshalText ¶
UnmarshalText will unmarshal/parse a DateTime from the given string.
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.
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 ¶
type ObjectCommon interface {
ObjectMetadata
HasAttribution
HasLocalization
HasTaxonomy
HasMedia
}
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) UnmarshalText ¶
UnmarshalText provides custom unmarshaling of String that will sanitize, unescape and trim whitespace from the value.