feed

package
v0.0.0-...-bcb87c1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CalendarContentType = "text/calendar; charset=utf-8"
View Source
const DefaultTTL = types.TTL(2 * time.Hour)

DefaultTTL is a general purpose slow TTL we use as a fallback for calendars that don't match more specific, faster TTLs. This is a constant, not configurable, since we don't want it to change and isn't really at the discretion of the operator.

Variables

View Source
var ErrNotModified = errors.New("feed has not been modified (cached, 304, etc)")

Functions

func TTLFor

func TTLFor(uri *url.URL, ttlMap map[types.NormalizedHostname]types.TTL) types.TTL

TTLFor returns the TTL for the given url.URL. It uses the hostname to search through config.Config IcalTTLMap.

func WithHttpClient

func WithHttpClient(c IHttpClient, cb func() error) error

WithHttpClient temporarily sets the http client used for fetching. Only use this when testing since it isn't threadsafe.

Types

type Feed

type Feed struct {
	Url         *url.URL
	HttpHeaders map[string]string
	HttpStatus  int
	Body        []byte
	MD5         types.MD5Hash
	FetchedAt   time.Time
}

func Fetch

func Fetch(ctx context.Context, u *url.URL, previousHeaders HeaderMap) (*Feed, error)

func New

func New(url *url.URL, headers map[string]string, httpStatus int, body []byte, fetchedAt time.Time) *Feed

func (*Feed) SetBody

func (f *Feed) SetBody(body []byte)

type HeaderMap

type HeaderMap map[string]string

func HeadersToMap

func HeadersToMap(h http.Header) HeaderMap

type IHttpClient

type IHttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

Jump to

Keyboard shortcuts

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