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.8.0 DO NOT EDIT.
Index ¶
- Variables
- func GetMedianInterval(data []time.Duration) time.Duration
- func IsImage(mimetype string) bool
- func ParseRFC822(ts string) (time.Time, error)
- type FeedSource
- type GeoInfo
- type HasAttribution
- type HasContent
- type HasGeo
- type HasID
- type HasLocalization
- type HasMedia
- type HasTaxonomy
- type Image
- type ItemSource
- type Link
- type LinkType
- type MediaEditable
- type ObjectCommon
- type ObjectMetadata
- type Person
- type Source
- type SourceURL
- type SourceURLEditable
Constants ¶
This section is empty.
Variables ¶
var DateOnlyLayoutsRFC822 = []string{ "Mon, 02 Jan 2006 15:04:05 -0700", "Mon, 02 Jan 06 15:04:05 -0700", "Mon, 02 Jan 2006 15:04:05", "Mon, 02 Jan 2006", "Mon, 2 Jan 2006", "Mon, 2 Jan 2006 15:04:05 -0700", "Mon, 2 Jan 06 15:04:05 -0700", "Monday, January 2, 2006", "02 Jan 2006 15:04:05 -0700", "02 Jan 06 15:04:05 -0700", "Mon, 02 Jan 2006 15:04 -0700", "Mon, 02 Jan 06 15:04 -0700", "Mon, 2 Jan 2006 15:04 -0700", "Mon, 2 Jan 06 15:04 -0700", "02 Jan 2006 15:04 -0700", "02 Jan 06 15:04 -0700", "2006 Jan 02 15:04:05 -0700", "2006 Jan 02 15:04:05 MST", "Jan 02, 2006", "2006-01-02T15:04:05+00:00", "2006-01-02T15:04:05+0000", "2006-01-02 15:04 MST", time.RFC3339, time.DateOnly, time.DateTime, }
DateOnlyLayoutsRFC822 are candidate layouts for parsing timestamps. Note that not all of these do conform to the spec, they are gathered from real-world usage in feeds. Where a timezone is included, it is ended in a literal "-0700" placeholder for a *numeric* offset. We normalize any named zone abbreviation in the input to a numeric offset before trying these, so a single set of layouts covers both cases.
var (
MimeTypesImage = []string{"image/avif", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/webp"}
)
var NamedZoneOffsetsRFC822 = map[string]int{
"UT": 0, "GMT": 0, "Z": 0,
"EST": -5 * 3600, "EDT": -4 * 3600,
"CST": -6 * 3600, "CDT": -5 * 3600,
"MST": -7 * 3600, "MDT": -6 * 3600,
"PST": -8 * 3600, "PDT": -7 * 3600,
}
NamedZoneOffsetsRFC822 maps RFC 822 zone abbreviations to their UTC offset in seconds. Go's time.Parse does NOT reliably resolve these itself. An unrecognized "MST"-style abbreviation is silently assigned a zero offset by the standard library, which would misparse e.g. "EST" as UTC. We look these up ourselves instead of trusting the stdlib's zone-name parsing.
Functions ¶
func GetMedianInterval ¶
GetMedianInterval calculates the median of the given set of time.Duration values.
func IsImage ¶
IsImage will return a boolean indicating whether the given mimetype represents an image.
func ParseRFC822 ¶
ParseRFC822 parses an RSS date-time value leniently: it accepts both numeric zone offsets (+0100, -0600) and the named zone abbreviations registered in namedZoneOffsets, with or without a weekday, with a 2- or 4-digit year, and with or without seconds.
Types ¶
type FeedSource ¶
type FeedSource interface {
ObjectCommon
SourceURL
SourceURLEditable
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 HasGeo ¶
type HasGeo interface {
GetGeoInfo() *GeoInfo
}
HasGeo represents an object that has geographical information.
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() *Image
}
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 Image ¶
type Image struct {
// Title is a description of the image (for example, the alt tag associated with the image).
Title *string `json:"title,omitempty"`
// URL the URL to the image.
URL string `json:"url" validate:"required,url"`
}
Image represents a remote image.
type ItemSource ¶
type ItemSource interface {
ObjectCommon
HasID
HasContent
HasGeo
// contains filtered or unexported methods
}
ItemSource is an abstraction representing an individual Item from any type of Feed source.
type Link ¶
type Link struct {
// Type is the type of address. While there are some canonical values for the type, they are not conclusive and the type can be any value, including one of the canonical types. However, a canonical type should be used whenever appropriate.
Type LinkType `json:"type" validate:"required"`
// Value is the link value. It can be a URI, email or any string that acts as a unique identifier (i.e., social media handle).
Value string `json:"value" validate:"required|uri|email"`
}
Link is an 'address', usually of a person. For example, an email, website or social media handle. An address has a type and a value and/or URI associated with it.
type LinkType ¶
type LinkType string
LinkType is the type of address. While there are some canonical values for the type, they are not conclusive and the type can be any value, including one of the canonical types. However, a canonical type should be used whenever appropriate.
type MediaEditable ¶
type MediaEditable interface {
SetImage(image *Image)
}
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 Person ¶
type Person struct {
// Bio is an optional short biography of the person.
Bio *string `json:"bio,omitempty"`
// Links are links associated with the person that provide more details about them.
Links []Link `json:"links,omitempty" validate:"omitempty,dive,unique"`
// Name is the person's name.
Name string `json:"name" validate:"required"`
}
Person represents a person.
type Source ¶
type Source string
Source 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.
type SourceURL ¶
type SourceURL interface {
GetSourceURL() string
}
SourceURL contains methods for retrieving or setting the source of the Object.
type SourceURLEditable ¶
type SourceURLEditable interface {
SetSourceURL(url string)
}
SourceURLEditable indicates the source URL for the object can be changed.