fetch

package
Version: v0.0.0-...-7cc0ef5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(iri *url.URL) (vocab.Type, error)

Fetch the resource at iri.

If a cached version of the resource at iri is available, that one is returned. If no cached version is available, creates an HTTP GET request that gets the resource.

func FetchIter

func FetchIter(it IterEntry) (vocab.Type, error)

Fetch the resource at it.

If a cached version of the resource at iri is available, that one is returned. If no cached version is available, creates an HTTP GET request that gets the resource.

func FetchIters

func FetchIters(it Iter) (vs []vocab.Type, err error)

Fetch all objects from iterator it.

If cached versions of the resources are available, these ones are returned. For each object for which no cached version is available, creates an HTTP GET request that gets the resource.

func Get

func Get(iri *url.URL) (body []byte, err error)

Issue an HTTP request that GETs the ActivityPub resource at iri.

func IRI

func IRI(ie IterEntry) (iri *url.URL, err error)

Given ie, return the IRI to that entry.

This will not involve any network request, the information is sourced from ie alone.

func IRIs

func IRIs(it Iter) (iris []*url.URL, err error)

Iterate over it and return IRIs to each element in that iterator.

This will not involve any network request, the information is sourced from ie alone.

func Post

func Post(body []byte, iri *url.URL) (err error)

Issue an HTTP request that POSTs body to the ActiviyPub endpoint at iri.

func Submit

func Submit(object vocab.Type, iri *url.URL) error

Submit activity pub payload object to iri. This should involve an HTTP POST request to iri.

Types

type Iter

type Iter interface {
	IterEntry

	Next() Iter
	End() Iter
}

A pimped version of IterEntry that also allows us to get the next item and determine whether we have reached the end. To iterate over some Iter, you would write code like this

for it := getIter(); it != it.End(); it = it.Next() {
    ...
}

func Begin

func Begin(iterable interface{}) (Iter, error)

Return a generic iterator over iterable.

If we don't know how to iterate over iterable or it is in fact not possible, an error is returned.

func Begins

func Begins(iterables ...interface{}) (Iter, error)

Given iterables, return an iterator that combines all of these iterators and returns the individual items in chronological order.

To sort the items in chronological order, IterEntrys that contain IRIs are dereferenced. We cannot know the published date of just an IRI after all.

type IterEntry

type IterEntry interface {
	// Returns wheter any value is set.
	HasAny() bool

	// Returns whether the underlying value is an IRI and not
	// a full object.
	IsIRI() bool

	// Return the underlying IRI. Only call this if IsIRI
	// returns true.
	GetIRI() *url.URL

	// Return the underlying object. Only call this if IsIRI
	// returns false and HasAny returns true.
	GetType() vocab.Type
}

A single entry of an iterator. Many of the go-fed iterator types implement this interface.

It either contains a vocab.Type instance, an IRI pointing to some object that can be represented as vocab.Type or nothing (in which case HasAny returns false).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL