client

package module
v0.0.0-...-1509966 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 19 Imported by: 13

README

About GoActivityPub: Client

MIT Licensed Build Status Test Coverage Go Report Card

This project is part of the GoActivityPub library which helps with creating ActivityPub applications using the Go programming language.

It can be used to create an API client for ActivityPub servers.

It supports retrieval of ActivityPub objects and collections, but also submitting Activities to servers, either as a C2S or as a S2S client.

It can supports plugging in custom authorization logic. We usually authorize the requests with either HTTP Singatures (for server to server interactions) or OAuth2 (for client to server interactions).

You can find an expanded documentation about the whole library on SourceHut.

For discussions about the projects you can write to the discussions mailing list: ~mariusor/go-activitypub-discuss@lists.sr.ht

For patches and bug reports please use the dev mailing list: ~mariusor/go-activitypub-dev@lists.sr.ht

Documentation

Index

Constants

View Source
const (
	ContentTypeJsonLD = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
	// ContentTypeActivityJson This specification registers the application/activity+json MIME Media Type
	// specifically for identifying documents conforming to the Activity Streams 2.0 format.
	//
	// https://www.w3.org/TR/activitystreams-core/#media-type
	ContentTypeActivityJson = `application/activity+json`
)
View Source
const MB = 1024 * 1024 * 1024

Variables

View Source
var UserAgent = "GoActivityPub DefaultClient (https://github.com/go-ap)"

UserAgent value that the client uses when performing requests

Functions

func ActivityActorTargetCollections

func ActivityActorTargetCollections(act vocab.Item, colFn iriGenFn) (vocab.IRIs, error)

func HTTPClient

func HTTPClient(c httpClient) *http.Client

func UserAgentTransport

func UserAgentTransport(ua string, wrap http.RoundTripper) http.RoundTripper

Types

type Basic

type Basic interface {
	LoadIRI(vocab.IRI) (vocab.Item, error)
	CtxLoadIRI(context.Context, vocab.IRI) (vocab.Item, error)
	ToCollection(vocab.Item, ...vocab.IRI) (vocab.IRI, vocab.Item, error)
	CtxToCollection(context.Context, vocab.Item, ...vocab.IRI) (vocab.IRI, vocab.Item, error)
}

type C

type C struct {
	// contains filtered or unexported fields
}

func New

func New(o ...OptionFn) *C

func (C) Activity

func (c C) Activity(ctx context.Context, iri vocab.IRI) (*vocab.Activity, error)

Activity dereferences the iri vocab.IRI as an activity object.

func (C) Actor

func (c C) Actor(ctx context.Context, iri vocab.IRI) (*vocab.Actor, error)

Actor dereferences the iri vocab.IRI as an actor object.

func (C) Collection

func (c C) Collection(ctx context.Context, iri vocab.IRI, ff ...filters.Check) (vocab.CollectionInterface, error)

Collection fetches the iri vocab.IRI as a collection. It applies filters to the received object.

func (C) CtxGet

func (c C) CtxGet(ctx context.Context, url string) (*http.Response, error)

CtxGet wrapper over the functionality offered by the default http.Client object

func (C) CtxLoadIRI

func (c C) CtxLoadIRI(ctx context.Context, id vocab.IRI) (vocab.Item, error)

CtxLoadIRI tries to dereference an IRI and load the full ActivityPub object it represents

func (C) CtxToCollection

func (c C) CtxToCollection(ctx context.Context, a vocab.Item, url ...vocab.IRI) (vocab.IRI, vocab.Item, error)

CtxToCollection

func (*C) Do

func (c *C) Do(req *http.Request) (*http.Response, error)

func (C) Followers

func (c C) Followers(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Followers fetches the followers collection of the actor Item. It applies filters to the received collection object.

func (C) Following

func (c C) Following(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Following fetches the following collection of the actor Item. It applies filters to the received collection object.

func (C) Inbox

func (c C) Inbox(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Inbox fetches the inbox collection of the actor Item. It applies filters to the received collection object.

func (C) Liked

func (c C) Liked(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Liked fetches the liked collection of the actor Item. It applies filters to the received collection object.

func (C) Likes

func (c C) Likes(ctx context.Context, object vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Likes fetches the likes collection of the object Item. It applies filters to the received collection object.

func (C) LoadIRI

func (c C) LoadIRI(id vocab.IRI) (vocab.Item, error)

LoadIRI tries to dereference an IRI and load the full ActivityPub object it represents

func (C) Object

func (c C) Object(ctx context.Context, iri vocab.IRI) (*vocab.Object, error)

Object dereferences the iri vocab.IRI as an object.

func (C) Outbox

func (c C) Outbox(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Outbox fetches the outbox collection of the actor Item. It applies filters to the received collection object.

func (C) Replies

func (c C) Replies(ctx context.Context, object vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Replies fetches the replies collection of the object Item. It applies filters to the received collection object.

func (C) Shares

func (c C) Shares(ctx context.Context, object vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)

Shares fetches the shares collection of the object Item. It applies filters to the received collection object.

func (C) ToCollection

func (c C) ToCollection(a vocab.Item, url ...vocab.IRI) (vocab.IRI, vocab.Item, error)

ToCollection

func (C) ToInbox

func (c C) ToInbox(ctx context.Context, act vocab.Item) (vocab.IRI, vocab.Item, error)

func (C) ToOutbox

func (c C) ToOutbox(ctx context.Context, act vocab.Item) (vocab.IRI, vocab.Item, error)

ToOutbox dispatches an Activity to its Actor's Outbox. It is the simplest mechanism to dispatch an ActivityPub Social API activity.

type Ctx

type Ctx = lw.Ctx

type CtxLogFn

type CtxLogFn func(...Ctx) LogFn

type LogFn

type LogFn func(string, ...any)

type OptionFn

type OptionFn func(s *C) error

OptionFn

func SkipTLSValidation

func SkipTLSValidation(skip bool) OptionFn

SkipTLSValidation sets the flag for skipping TLS validation on the default HTTP transport.

func WithHTTPClient

func WithHTTPClient(h *http.Client) OptionFn

WithHTTPClient sets the http client

func WithLogger

func WithLogger(l lw.Logger) OptionFn

type PubClient

type PubClient interface {
	PubGetter
	PubSubmitter
}

type PubGetter

type PubGetter interface {
	Inbox(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Outbox(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Following(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Followers(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Likes(ctx context.Context, object vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Liked(ctx context.Context, actor vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Replies(ctx context.Context, object vocab.Item, ff ...filters.Check) (vocab.CollectionInterface, error)
	Collection(ctx context.Context, i vocab.IRI, ff ...filters.Check) (vocab.CollectionInterface, error)

	Actor(ctx context.Context, iri vocab.IRI) (*vocab.Actor, error)
	Activity(ctx context.Context, iri vocab.IRI) (*vocab.Activity, error)
	Object(ctx context.Context, iri vocab.IRI) (*vocab.Object, error)
}

type PubSubmitter

type PubSubmitter interface {
	ToOutbox(ctx context.Context, a vocab.Item) (vocab.IRI, vocab.Item, error)
	ToInbox(ctx context.Context, a vocab.Item) (vocab.IRI, vocab.Item, error)
}

type RequestSignFn

type RequestSignFn func(*http.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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