Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPClient(c C) *http.Client
- type Basic
- type C
- func (c C) Activity(ctx context.Context, iri vocab.IRI) (*vocab.Activity, error)
- func (c C) Actor(ctx context.Context, iri vocab.IRI) (*vocab.Actor, error)
- func (c C) Collection(ctx context.Context, i vocab.IRI, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) CtxGet(ctx context.Context, url string) (*http.Response, error)
- func (c C) CtxLoadIRI(ctx context.Context, id vocab.IRI) (vocab.Item, error)
- func (c C) CtxPost(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, error)
- func (c C) CtxToCollection(ctx context.Context, url vocab.IRI, a vocab.Item) (vocab.IRI, vocab.Item, error)
- func (c C) Delete(url, contentType string, body io.Reader) (*http.Response, error)
- func (c *C) Do(req *http.Request) (*http.Response, error)
- func (c C) Followers(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Following(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Get(url string) (*http.Response, error)
- func (c C) Head(url string) (*http.Response, error)
- func (c C) Inbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Liked(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Likes(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) LoadIRI(id vocab.IRI) (vocab.Item, error)
- func (c C) Object(ctx context.Context, iri vocab.IRI) (*vocab.Object, error)
- func (c C) Outbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Post(url, contentType string, body io.Reader) (*http.Response, error)
- func (c C) Put(url, contentType string, body io.Reader) (*http.Response, error)
- func (c C) Replies(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) Shares(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
- func (c C) ToCollection(url vocab.IRI, a vocab.Item) (vocab.IRI, vocab.Item, error)
- func (c C) ToInbox(ctx context.Context, a vocab.Item) (vocab.IRI, vocab.Item, error)
- func (c C) ToOutbox(ctx context.Context, a vocab.Item) (vocab.IRI, vocab.Item, error)
- type Ctx
- type CtxLogFn
- type ErrorHandlerFunc
- type FilterFn
- type LogFn
- type OptionFn
- type PubClient
- type PubGetter
- type PubSubmitter
- type RequestSignFn
Constants ¶
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` )
const MB = 1024 * 1024 * 1024
Variables ¶
var UserAgent = "activitypub-go-http-client"
UserAgent value that the client uses when performing requests
Functions ¶
func HTTPClient ¶
Types ¶
type C ¶
type C struct {
// contains filtered or unexported fields
}
func (C) Collection ¶
func (c C) Collection(ctx context.Context, i vocab.IRI, filters ...FilterFn) (vocab.CollectionInterface, error)
Collection
func (C) CtxLoadIRI ¶
CtxLoadIRI tries to dereference an IRI and load the full ActivityPub object it represents
func (C) CtxPost ¶
func (c C) CtxPost(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, error)
CtxPost wrapper over the functionality offered by the default http.Client object
func (C) CtxToCollection ¶
func (c C) CtxToCollection(ctx context.Context, url vocab.IRI, a vocab.Item) (vocab.IRI, vocab.Item, error)
CtxToCollection
func (C) Followers ¶
func (c C) Followers(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Followers
func (C) Following ¶
func (c C) Following(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Following
func (C) Inbox ¶
func (c C) Inbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Inbox
func (C) Liked ¶
func (c C) Liked(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Liked
func (C) Likes ¶
func (c C) Likes(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Likes
func (C) LoadIRI ¶
LoadIRI tries to dereference an IRI and load the full ActivityPub object it represents
func (C) Outbox ¶
func (c C) Outbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Outbox
func (C) Replies ¶
func (c C) Replies(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Replies
func (C) Shares ¶
func (c C) Shares(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error)
Shares
func (C) ToCollection ¶
ToCollection
type ErrorHandlerFunc ¶
type ErrorHandlerFunc func(...error) http.HandlerFunc
ErrorHandlerFunc is a data type for the default ErrorHandler function of the package
var ErrorHandler ErrorHandlerFunc = func(errors ...error) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { output := bytes.Buffer{} for i, e := range errors { output.WriteString(fmt.Sprintf("#%d %s\n", i, e.Error())) } w.WriteHeader(http.StatusInternalServerError) w.Header().Add("Content-Type", "text/plain") _, _ = w.Write(output.Bytes()) } }
ErrorHandler is the error handler callback for the ActivityPub package. It can be overloaded from the packages that require it
type OptionFn ¶
OptionFn
func SetDefaultHTTPClient ¶
func SetDefaultHTTPClient() OptionFn
SetDefaultHTTPClient is a hacky solution to modify the default static instance of the http.DefaultClient to whatever we have instantiated currently. This ensures that options like SkipTLSValidation propagate to the requests that are not done explicitly by us, because we assume it will be executed under the same constraints.
func SkipTLSValidation ¶
SkipTLSValidation sets the flag for skipping TLS validation on the default HTTP transport.
func WithHTTPClient ¶
WithHTTPClient sets the http client
func WithLogger ¶
type PubClient ¶
type PubClient interface { PubGetter PubSubmitter }
type PubGetter ¶
type PubGetter interface { Inbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Outbox(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Following(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Followers(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Likes(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Liked(ctx context.Context, actor vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Replies(ctx context.Context, object vocab.Item, filters ...FilterFn) (vocab.CollectionInterface, error) Collection(ctx context.Context, i vocab.IRI, filters ...FilterFn) (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) }