Documentation
¶
Index ¶
- Variables
- func Decode[T any](namespace string, b []byte) (T, error)
- func DiscoverFeedURL(sourceURL *url.URL, content []byte) (string, error)
- func DiscoverPageImage(pageURL string, timeout time.Duration) (*types.ImageInfo, error)
- func Encode[T any](feed T) ([]byte, error)
- type Feed
- type HTTPError
- type Item
- type ParseOption
- type ParserOptions
- type SourceType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrParseBytes indicates an error occurred trying to parse a byte array as a feed. ErrParseBytes = errors.New("unable to parse bytes as feed") // ErrParseURL indicates an error occurred trying to parse a URL as a feed. ErrParseURL = errors.New("unable to parse URL as feed") // ErrUnsupportedFormat indicates that feed format is not known and cannot be parsed. ErrUnsupportedFormat = errors.New("unsupported feed format") )
var ErrUnmarshal = errors.New("unmarshaling object failed")
ErrUnmarshal indicates an error occurred trying to unmarshal data into a given feed object.
Functions ¶
func Decode ¶
Decode will decode the byte array into the given type T, and assign values without a namespace with the given namespace.
func DiscoverFeedURL ¶
DiscoverFeedURL attempts to find a feed URL within a HTML page.
There are a couple of "canonical" places the feed URL is located. Firstly, as per the RSS spec, look for a link element with rel="alternate" and type="application/rss+xml". Secondly, check for a link element with a URL that ends with feed, rss or atom, which would indicate a feed URL.
func DiscoverPageImage ¶
DiscoverPageImage attempts to find a suitable image to use for a page.
Types ¶
type Feed ¶
type Feed struct {
types.FeedSource `json:"source"`
SourceType SourceType `json:"type"`
}
Feed represents any feed type containing a number of items.
func NewFeedFromBytes ¶
func NewFeedFromBytes[T any](data []byte, options ...ParseOption) (*Feed, error)
NewFeedFromBytes will create a new Feed of the given type from the given byte array.
func NewFeedFromSource ¶
func NewFeedFromSource[T types.FeedSource](source T, options ...ParseOption) *Feed
NewFeedFromSource will create a new Feed from the given source that satisfies the FeedSource interface. This can be used to create a Feed from an existing rss.RSS or atom.Feed object.
func NewFeedFromURL ¶
NewFeedFromURL attempts to parse the given URL as a feed source.
func (*Feed) UnmarshalJSON ¶
UnmarshalJSON handles unmarshaling of a Feed from JSON.
type Item ¶
type Item struct {
types.ItemSource `json:"source"`
SourceType SourceType `json:"type"`
FeedTitle string `json:"feed_title"`
}
Item represents a single item or entry (or article) in a feed.
func (*Item) UnmarshalJSON ¶
UnmarshalJSON handles unmarshaling of an Item from JSON.
type ParseOption ¶
type ParseOption func(*ParserOptions)
func PerformValidation ¶
func PerformValidation(value bool) ParseOption
PerformValidation option controls whether validation will be performed after the feed data has been parsed. This allows a feed that doesn't strictly pass its format specification to be returned.
func WithClient ¶
func WithClient(client *resty.Client) ParseOption
WithClient option allows using a custom client for any network requests to fetch feed resources.
type ParserOptions ¶
type ParserOptions struct {
// contains filtered or unexported fields
}
type SourceType ¶
type SourceType string
SourceType is a string constant that indicates the underlying source data type of a Feed/Item object. This is mainly used when unmarshaling from JSON where the JSON structure of the source types can be ambiguous.
const ( // TypeRSS indicates the source data was from an RSS feed. TypeRSS SourceType = "RSS" // TypeAtom indicates the source data was from an Atom feed. TypeAtom SourceType = "Atom" // TypeJSONFeed indicates the source data was from a JSONFeed feed. TypeJSONFeed SourceType = "JSONFeed" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package atom provides primitives to interact with the openapi HTTP API.
|
Package atom provides primitives to interact with the openapi HTTP API. |
|
extensions
|
|
|
dc
Package dc provides primitives to interact with the openapi HTTP API.
|
Package dc provides primitives to interact with the openapi HTTP API. |
|
googleplay
Package googleplay provides primitives to interact with the openapi HTTP API.
|
Package googleplay provides primitives to interact with the openapi HTTP API. |
|
itunes
Package itunes provides primitives to interact with the openapi HTTP API.
|
Package itunes provides primitives to interact with the openapi HTTP API. |
|
media
Package media provides primitives to interact with the openapi HTTP API.
|
Package media provides primitives to interact with the openapi HTTP API. |
|
rss
Package rss provides primitives to interact with the openapi HTTP API.
|
Package rss provides primitives to interact with the openapi HTTP API. |
|
Package jsonfeed provides primitives to interact with the openapi HTTP API.
|
Package jsonfeed provides primitives to interact with the openapi HTTP API. |
|
Package opengraph provides primitives to interact with the openapi HTTP API.
|
Package opengraph provides primitives to interact with the openapi HTTP API. |
|
Package opml provides primitives to interact with the openapi HTTP API.
|
Package opml provides primitives to interact with the openapi HTTP API. |
|
Package rss provides primitives to interact with the openapi HTTP API.
|
Package rss provides primitives to interact with the openapi HTTP API. |
|
Package schema contains the OpenAPI schema definitions for go-syndication.
|
Package schema contains the OpenAPI schema definitions for go-syndication. |
|
Package sitemap provides primitives to interact with the openapi HTTP API.
|
Package sitemap provides primitives to interact with the openapi HTTP API. |
|
Package types provides primitives to interact with the openapi HTTP API.
|
Package types provides primitives to interact with the openapi HTTP API. |