Documentation ¶
Index ¶
- Constants
- Variables
- func Marshal(o interface{}) ([]byte, error)
- func MarshalJSON(o interface{}, others ...interface{}) ([]byte, error)
- func MustParseURL(raw string) *url.URL
- func UnmarshalFromDoc(doc Document, obj interface{}) error
- func UnmarshalJSON(b []byte, objects ...interface{}) error
- type ActivityOptions
- type ActivityType
- func NewAcceptActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewAnnounceActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewCreateActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewFollowActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewInviteActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewLikeActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewOfferActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewRejectActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func NewUndoActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
- func (t *ActivityType) Actor() *url.URL
- func (t *ActivityType) MarshalJSON() ([]byte, error)
- func (t *ActivityType) Object() *ObjectProperty
- func (t *ActivityType) Result() *ObjectProperty
- func (t *ActivityType) SetActor(iri *url.URL)
- func (t *ActivityType) Target() *ObjectProperty
- func (t *ActivityType) UnmarshalJSON(bytes []byte) error
- type ActorOptions
- type ActorType
- func (t *ActorType) Followers() *url.URL
- func (t *ActorType) Following() *url.URL
- func (t *ActorType) Inbox() *url.URL
- func (t *ActorType) Liked() *url.URL
- func (t *ActorType) MarshalJSON() ([]byte, error)
- func (t *ActorType) Outbox() *url.URL
- func (t *ActorType) PublicKey() *PublicKeyType
- func (t *ActorType) UnmarshalJSON(bytes []byte) error
- func (t *ActorType) Witnesses() *url.URL
- func (t *ActorType) Witnessing() *url.URL
- type AnchorEventOptions
- type AnchorEventType
- type CollectionOptions
- type CollectionPageType
- type CollectionType
- func (t *CollectionType) Current() *url.URL
- func (t *CollectionType) First() *url.URL
- func (t *CollectionType) Items() []*ObjectProperty
- func (t *CollectionType) Last() *url.URL
- func (t *CollectionType) MarshalJSON() ([]byte, error)
- func (t *CollectionType) TotalItems() int
- func (t *CollectionType) UnmarshalJSON(bytes []byte) error
- type Context
- type ContextProperty
- func (p *ContextProperty) Contains(contexts ...Context) bool
- func (p *ContextProperty) ContainsAny(contexts ...Context) bool
- func (p *ContextProperty) Contexts() []Context
- func (p *ContextProperty) MarshalJSON() ([]byte, error)
- func (p *ContextProperty) String() string
- func (p *ContextProperty) UnmarshalJSON(bytes []byte) error
- type Document
- type LinkType
- type MediaType
- type ObjectProperty
- func (p *ObjectProperty) Activity() *ActivityType
- func (p *ObjectProperty) AnchorEvent() *AnchorEventType
- func (p *ObjectProperty) Collection() *CollectionType
- func (p *ObjectProperty) Document() Document
- func (p *ObjectProperty) IRI() *url.URL
- func (p *ObjectProperty) MarshalJSON() ([]byte, error)
- func (p *ObjectProperty) Object() *ObjectType
- func (p *ObjectProperty) OrderedCollection() *OrderedCollectionType
- func (p *ObjectProperty) Type() *TypeProperty
- func (p *ObjectProperty) UnmarshalJSON(bytes []byte) error
- type ObjectPropertyOptions
- type ObjectType
- func (t *ObjectType) Attachment() []*ObjectProperty
- func (t *ObjectType) AttributedTo() *URLProperty
- func (t *ObjectType) CID() string
- func (t *ObjectType) Context() *ContextProperty
- func (t *ObjectType) EndTime() *time.Time
- func (t *ObjectType) Generator() string
- func (t *ObjectType) ID() *URLProperty
- func (t *ObjectType) InReplyTo() *URLProperty
- func (t *ObjectType) MarshalJSON() ([]byte, error)
- func (t *ObjectType) Published() *time.Time
- func (t *ObjectType) SetID(id *url.URL)
- func (t *ObjectType) StartTime() *time.Time
- func (t *ObjectType) Tag() []*TagProperty
- func (t *ObjectType) To() Urls
- func (t *ObjectType) Type() *TypeProperty
- func (t *ObjectType) URL() Urls
- func (t *ObjectType) UnmarshalJSON(bytes []byte) error
- func (t *ObjectType) Value(key string) (interface{}, bool)
- type Opt
- func WithActivity(activity *ActivityType) Opt
- func WithActor(actor *url.URL) Opt
- func WithAnchorEvent(anchorEvt *AnchorEventType) Opt
- func WithAttachment(obj ...*ObjectProperty) Opt
- func WithCollection(coll *CollectionType) Opt
- func WithContext(context ...Context) Opt
- func WithCurrent(current *url.URL) Opt
- func WithDocument(doc Document) Opt
- func WithEndTime(t *time.Time) Opt
- func WithFirst(first *url.URL) Opt
- func WithFollowers(followers *url.URL) Opt
- func WithFollowing(following *url.URL) Opt
- func WithID(id *url.URL) Opt
- func WithIRI(iri *url.URL) Opt
- func WithInReplyTo(id *url.URL) Opt
- func WithInbox(inbox *url.URL) Opt
- func WithLast(last *url.URL) Opt
- func WithLiked(liked *url.URL) Opt
- func WithLikes(likes *url.URL) Opt
- func WithLink(link *LinkType) Opt
- func WithNext(next *url.URL) Opt
- func WithObject(obj *ObjectType) Opt
- func WithOrderedCollection(coll *OrderedCollectionType) Opt
- func WithOutbox(outbox *url.URL) Opt
- func WithOwner(owner *url.URL) Opt
- func WithPartOf(partOf *url.URL) Opt
- func WithPrev(prev *url.URL) Opt
- func WithPublicKey(publicKey *PublicKeyType) Opt
- func WithPublicKeyPem(pem string) Opt
- func WithPublishedTime(t *time.Time) Opt
- func WithResult(result *ObjectProperty) Opt
- func WithShares(shares *url.URL) Opt
- func WithStartTime(t *time.Time) Opt
- func WithTag(tag *TagProperty) Opt
- func WithTarget(target *ObjectProperty) Opt
- func WithTo(to ...*url.URL) Opt
- func WithTotalItems(totalItems int) Opt
- func WithType(t ...Type) Opt
- func WithURL(u ...*url.URL) Opt
- func WithWitnesses(witnesses *url.URL) Opt
- func WithWitnessing(witnessing *url.URL) Opt
- type Options
- type OrderedCollectionPageType
- type OrderedCollectionType
- type PublicKeyOptions
- type PublicKeyType
- type Relationship
- type TagProperty
- type Type
- type TypeProperty
- func (p *TypeProperty) Is(types ...Type) bool
- func (p *TypeProperty) IsActivity() bool
- func (p *TypeProperty) IsAny(types ...Type) bool
- func (p *TypeProperty) MarshalJSON() ([]byte, error)
- func (p *TypeProperty) String() string
- func (p *TypeProperty) Types() []Type
- func (p *TypeProperty) UnmarshalJSON(bytes []byte) error
- type URLCollectionProperty
- type URLProperty
- type Urls
Constants ¶
const (
// RelationshipWitness defines the 'witness' relationship of a Link.
RelationshipWitness = "witness"
)
Variables ¶
var ( // PublicIRI indicates that the object is public, i.e. it may be viewed by anyone. PublicIRI = MustParseURL("https://www.w3.org/ns/activitystreams#Public") // AnchorWitnessTargetIRI indicates that the object/target of the activity is an anchor witness. AnchorWitnessTargetIRI = MustParseURL("https://w3id.org/activityanchors#AnchorWitness") )
Functions ¶
func Marshal ¶ added in v0.1.1
Marshal marshals the given object to a JSON representation without escaping characters such as '&', '<' and '>'.
func MarshalJSON ¶
MarshalJSON marshals the given objects (merging them into one document) and returns the marshaled JSON result.
func MustParseURL ¶ added in v0.1.1
MustParseURL parses the string and returns the URL. This function panics if the string is not a valid URL.
func UnmarshalFromDoc ¶ added in v1.0.0
UnmarshalFromDoc unmarshals the given document to the given object.
func UnmarshalJSON ¶
UnmarshalJSON unmarshals the given bytes to the set of provided objects.
Types ¶
type ActivityOptions ¶
type ActivityOptions struct { Result *ObjectProperty Actor *url.URL Target *ObjectProperty }
ActivityOptions holds the options for an Activity.
type ActivityType ¶
type ActivityType struct { *ObjectType // contains filtered or unexported fields }
ActivityType defines an 'activity'.
func NewAcceptActivity ¶
func NewAcceptActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewAcceptActivity returns a new 'Accept' activity.
func NewAnnounceActivity ¶
func NewAnnounceActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewAnnounceActivity returns a new 'Announce' activity.
func NewCreateActivity ¶
func NewCreateActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewCreateActivity returns a new 'Create' activity.
func NewFollowActivity ¶
func NewFollowActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewFollowActivity returns a new 'Follow' activity.
func NewInviteActivity ¶ added in v0.1.3
func NewInviteActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewInviteActivity returns a new 'InviteWitness' activity.
func NewLikeActivity ¶
func NewLikeActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewLikeActivity returns a new 'Like' activity.
func NewOfferActivity ¶
func NewOfferActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewOfferActivity returns a new 'Offer' activity.
func NewRejectActivity ¶
func NewRejectActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewRejectActivity returns a new 'Reject' activity.
func NewUndoActivity ¶
func NewUndoActivity(obj *ObjectProperty, opts ...Opt) *ActivityType
NewUndoActivity returns a new 'Undo' activity.
func (*ActivityType) Actor ¶
func (t *ActivityType) Actor() *url.URL
Actor returns the actor for the activity.
func (*ActivityType) MarshalJSON ¶
func (t *ActivityType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the activity.
func (*ActivityType) Object ¶
func (t *ActivityType) Object() *ObjectProperty
Object returns the object of the activity.
func (*ActivityType) Result ¶
func (t *ActivityType) Result() *ObjectProperty
Result returns the result.
func (*ActivityType) SetActor ¶
func (t *ActivityType) SetActor(iri *url.URL)
SetActor sets the actor for the activity.
func (*ActivityType) Target ¶
func (t *ActivityType) Target() *ObjectProperty
Target returns the target of the activity.
func (*ActivityType) UnmarshalJSON ¶
func (t *ActivityType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the activity.
type ActorOptions ¶
type ActorOptions struct { PublicKey *PublicKeyType Inbox *url.URL Outbox *url.URL Followers *url.URL Following *url.URL Witnesses *url.URL Witnessing *url.URL Liked *url.URL Likes *url.URL }
ActorOptions holds the options for an Activity.
type ActorType ¶
type ActorType struct { *ObjectType // contains filtered or unexported fields }
ActorType defines an 'actor'.
func NewService ¶
NewService returns a new 'Service' actor type.
func (*ActorType) MarshalJSON ¶
MarshalJSON mmarshals the object to JSON.
func (*ActorType) PublicKey ¶
func (t *ActorType) PublicKey() *PublicKeyType
PublicKey returns the actor's public key.
func (*ActorType) UnmarshalJSON ¶
UnmarshalJSON ummarshals the object from JSON.
func (*ActorType) Witnessing ¶
Witnessing returns the URL of what the actor is witnessing.
type AnchorEventOptions ¶ added in v1.0.0
type AnchorEventOptions struct {
AnchorEvent *AnchorEventType
}
AnchorEventOptions holds the options for an AnchorEvent.
type AnchorEventType ¶ added in v1.0.0
type AnchorEventType struct { *ObjectType // contains filtered or unexported fields }
AnchorEventType defines an "AnchorEvent" type.
func NewAnchorEvent ¶ added in v1.0.0
func NewAnchorEvent(obj *ObjectProperty, opts ...Opt) *AnchorEventType
NewAnchorEvent returns a new AnchorEvent type.
func (*AnchorEventType) MarshalJSON ¶ added in v1.0.0
func (t *AnchorEventType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the object to JSON.
func (*AnchorEventType) Object ¶ added in v1.0.0
func (t *AnchorEventType) Object() *ObjectProperty
Object returns the Object property.
func (*AnchorEventType) UnmarshalJSON ¶ added in v1.0.0
func (t *AnchorEventType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON umarshals the object from JSON.
func (*AnchorEventType) Validate ¶ added in v1.0.0
func (t *AnchorEventType) Validate() error
Validate validates the anchor event.
type CollectionOptions ¶
type CollectionOptions struct { TotalItems int First *url.URL Last *url.URL Current *url.URL PartOf *url.URL Next *url.URL Prev *url.URL }
CollectionOptions holds the options for a Collection or OrderedCollection.
type CollectionPageType ¶
type CollectionPageType struct { *CollectionType // contains filtered or unexported fields }
CollectionPageType defines a "CollectionPage" type.
func NewCollectionPage ¶
func NewCollectionPage(items []*ObjectProperty, opts ...Opt) *CollectionPageType
NewCollectionPage returns a new collection page.
func (*CollectionPageType) MarshalJSON ¶
func (t *CollectionPageType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the collection page.
func (*CollectionPageType) Next ¶
func (t *CollectionPageType) Next() *url.URL
Next return the URL that may be used to retrieve the next page.
func (*CollectionPageType) PartOf ¶
func (t *CollectionPageType) PartOf() *url.URL
PartOf return the URL of the collection of which this page is a part.
func (*CollectionPageType) Prev ¶
func (t *CollectionPageType) Prev() *url.URL
Prev return the URL that may be used to retrieve the previous page.
func (*CollectionPageType) UnmarshalJSON ¶
func (t *CollectionPageType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the collection page.
type CollectionType ¶
type CollectionType struct { *ObjectType // contains filtered or unexported fields }
CollectionType defines a "Collection" type.
func NewCollection ¶
func NewCollection(items []*ObjectProperty, opts ...Opt) *CollectionType
NewCollection returns a new collection.
func (*CollectionType) Current ¶
func (t *CollectionType) Current() *url.URL
Current returns the current item.
func (*CollectionType) First ¶
func (t *CollectionType) First() *url.URL
First returns a URL that may be used to retrieve the first item in the collection.
func (*CollectionType) Items ¶
func (t *CollectionType) Items() []*ObjectProperty
Items returns the items in the collection.
func (*CollectionType) Last ¶
func (t *CollectionType) Last() *url.URL
Last returns a URL that may be used to retrieve the last item in the collection.
func (*CollectionType) MarshalJSON ¶
func (t *CollectionType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the object to JSON.
func (*CollectionType) TotalItems ¶
func (t *CollectionType) TotalItems() int
TotalItems returns the total number of items in the collection.
func (*CollectionType) UnmarshalJSON ¶
func (t *CollectionType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the object from JSON.
type Context ¶
type Context = string
Context defines the object context.
const ( // ContextActivityStreams is the ActivityStreams context. ContextActivityStreams Context = "https://www.w3.org/ns/activitystreams" // ContextSecurity is the security context. ContextSecurity Context = "https://w3id.org/security/v1" // ContextCredentials is the verifiable credential context. ContextCredentials Context = "https://www.w3.org/2018/credentials/v1" //nolint:gosec // ContextActivityAnchors is the Activity Anchors context. ContextActivityAnchors Context = "https://w3id.org/activityanchors/v1" )
type ContextProperty ¶
type ContextProperty struct {
// contains filtered or unexported fields
}
ContextProperty holds one or more contexts.
func NewContextProperty ¶
func NewContextProperty(context ...Context) *ContextProperty
NewContextProperty returns a new 'context' property. Nil is returned if no context was provided.
func (*ContextProperty) Contains ¶
func (p *ContextProperty) Contains(contexts ...Context) bool
Contains returns true if the property contains all of the given contexts.
func (*ContextProperty) ContainsAny ¶
func (p *ContextProperty) ContainsAny(contexts ...Context) bool
ContainsAny returns true if the property contains any of the given contexts.
func (*ContextProperty) Contexts ¶
func (p *ContextProperty) Contexts() []Context
Contexts returns all of the contexts defined in the property.
func (*ContextProperty) MarshalJSON ¶
func (p *ContextProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the context property.
func (*ContextProperty) String ¶
func (p *ContextProperty) String() string
String returns the string representation of the context property.
func (*ContextProperty) UnmarshalJSON ¶
func (p *ContextProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the context property.
type Document ¶
type Document map[string]interface{}
Document defines a JSON document as a map.
func MarshalToDoc ¶
MarshalToDoc marshals the given object to a Document.
func MustMarshalToDoc ¶ added in v1.0.0
func MustMarshalToDoc(obj interface{}) Document
MustMarshalToDoc marshals the given object to a Document.
func MustUnmarshalToDoc ¶
MustUnmarshalToDoc unmarshals the given bytes to a Document. If an error occurs then the function panics.
func UnmarshalToDoc ¶
UnmarshalToDoc unmarshals the given bytes to a Document.
type LinkType ¶ added in v1.0.0
type LinkType struct {
// contains filtered or unexported fields
}
LinkType defines the ActivityPub 'Link' type.
func (*LinkType) MarshalJSON ¶ added in v1.0.0
MarshalJSON marshals the link type to JSON.
func (*LinkType) Rel ¶ added in v1.0.0
func (t *LinkType) Rel() Relationship
Rel returns the relationship ('rel' field).
func (*LinkType) Type ¶ added in v1.0.0
func (t *LinkType) Type() *TypeProperty
Type always returns the "Link" type.
func (*LinkType) UnmarshalJSON ¶ added in v1.0.0
UnmarshalJSON umarshals the link type from JSON.
type MediaType ¶ added in v1.0.0
type MediaType = string
MediaType defines a type of encoding for content embedded within a document.
type ObjectProperty ¶
type ObjectProperty struct {
// contains filtered or unexported fields
}
ObjectProperty defines an 'object' property. The property may be a simple IRI or an embedded object such as 'Collection', 'OrderedCollection', 'Activity', etc.
func NewObjectProperty ¶
func NewObjectProperty(opts ...Opt) *ObjectProperty
NewObjectProperty returns a new 'object' property with the given options.
func (*ObjectProperty) Activity ¶
func (p *ObjectProperty) Activity() *ActivityType
Activity returns the activity or nil if the activity is not set.
func (*ObjectProperty) AnchorEvent ¶ added in v1.0.0
func (p *ObjectProperty) AnchorEvent() *AnchorEventType
AnchorEvent returns the anchor event or nil if the anchor event is not set.
func (*ObjectProperty) Collection ¶
func (p *ObjectProperty) Collection() *CollectionType
Collection returns the collection or nil if the collection is not set.
func (*ObjectProperty) Document ¶ added in v1.0.0
func (p *ObjectProperty) Document() Document
Document returns a document or nil if no document was set.
func (*ObjectProperty) IRI ¶
func (p *ObjectProperty) IRI() *url.URL
IRI returns the IRI or nil if the IRI is not set.
func (*ObjectProperty) MarshalJSON ¶
func (p *ObjectProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the 'object' property.
func (*ObjectProperty) Object ¶
func (p *ObjectProperty) Object() *ObjectType
Object returns the object or nil if the object is not set.
func (*ObjectProperty) OrderedCollection ¶
func (p *ObjectProperty) OrderedCollection() *OrderedCollectionType
OrderedCollection returns the ordered collection or nil if the ordered collection is not set.
func (*ObjectProperty) Type ¶
func (p *ObjectProperty) Type() *TypeProperty
Type returns the type of the object property. If the property is an IRI then nil is returned.
func (*ObjectProperty) UnmarshalJSON ¶
func (p *ObjectProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the 'object' property.
type ObjectPropertyOptions ¶
type ObjectPropertyOptions struct { Iri *url.URL Object *ObjectType Collection *CollectionType OrderedCollection *OrderedCollectionType Activity *ActivityType Document Document }
ObjectPropertyOptions holds options for an 'object' property.
type ObjectType ¶
type ObjectType struct {
// contains filtered or unexported fields
}
ObjectType defines an 'object'.
func NewObjectWithDocument ¶
func NewObjectWithDocument(doc Document, opts ...Opt) (*ObjectType, error)
NewObjectWithDocument returns a new object initialized with the given document.
func (*ObjectType) Attachment ¶ added in v0.1.3
func (t *ObjectType) Attachment() []*ObjectProperty
Attachment returns the 'attachment' field.
func (*ObjectType) AttributedTo ¶ added in v1.0.0
func (t *ObjectType) AttributedTo() *URLProperty
AttributedTo returns the 'attributedTo' field.
func (*ObjectType) Context ¶
func (t *ObjectType) Context() *ContextProperty
Context returns the context property.
func (*ObjectType) EndTime ¶
func (t *ObjectType) EndTime() *time.Time
EndTime returns the end time.
func (*ObjectType) Generator ¶ added in v1.0.0
func (t *ObjectType) Generator() string
Generator returns the 'generator' field.
func (*ObjectType) InReplyTo ¶ added in v0.1.3
func (t *ObjectType) InReplyTo() *URLProperty
InReplyTo returns the 'inReplyTo' field.
func (*ObjectType) MarshalJSON ¶
func (t *ObjectType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the object.
func (*ObjectType) Published ¶
func (t *ObjectType) Published() *time.Time
Published returns the time when the object was published.
func (*ObjectType) StartTime ¶
func (t *ObjectType) StartTime() *time.Time
StartTime returns the start time.
func (*ObjectType) Tag ¶ added in v1.0.0
func (t *ObjectType) Tag() []*TagProperty
Tag returns the 'tag' field.
func (*ObjectType) To ¶
func (t *ObjectType) To() Urls
To returns a set of URLs to which the object should be sent.
func (*ObjectType) Type ¶
func (t *ObjectType) Type() *TypeProperty
Type returns the type of the object.
func (*ObjectType) URL ¶ added in v0.1.3
func (t *ObjectType) URL() Urls
URL returns the object's URLs.
func (*ObjectType) UnmarshalJSON ¶
func (t *ObjectType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the object.
func (*ObjectType) Value ¶
func (t *ObjectType) Value(key string) (interface{}, bool)
Value returns the value of a property.
type Opt ¶
type Opt func(opts *Options)
Opt is an for an object, activity, etc.
func WithActivity ¶
func WithActivity(activity *ActivityType) Opt
WithActivity sets the 'object' property to an embedded activity.
func WithAnchorEvent ¶ added in v1.0.0
func WithAnchorEvent(anchorEvt *AnchorEventType) Opt
WithAnchorEvent sets the 'object' property.
func WithAttachment ¶ added in v0.1.3
func WithAttachment(obj ...*ObjectProperty) Opt
WithAttachment sets the 'attachment' property on the object.
func WithCollection ¶
func WithCollection(coll *CollectionType) Opt
WithCollection sets the 'object' property to an embedded collection.
func WithContext ¶
WithContext sets the 'context' property on the object.
func WithCurrent ¶
WithCurrent sets the 'current' property on the collection or ordered collection.
func WithDocument ¶ added in v1.0.0
WithDocument sets a raw document.
func WithEndTime ¶
WithEndTime sets the 'endTime' property on the object.
func WithFollowers ¶
WithFollowers sets the 'followers' property on the actor.
func WithFollowing ¶
WithFollowing sets the 'following' property on the actor.
func WithInReplyTo ¶ added in v0.1.3
WithInReplyTo sets the 'inReplyTo' property on the object.
func WithObject ¶
func WithObject(obj *ObjectType) Opt
WithObject sets the 'object' property to an embedded object.
func WithOrderedCollection ¶
func WithOrderedCollection(coll *OrderedCollectionType) Opt
WithOrderedCollection sets the 'object' property to an embedded ordered collection.
func WithOutbox ¶
WithOutbox sets the 'outbox' property on the actor.
func WithPartOf ¶
WithPartOf sets the 'partOf' property on a collection page or ordered collection page.
func WithPublicKey ¶
func WithPublicKey(publicKey *PublicKeyType) Opt
WithPublicKey sets the 'publicKey' property on the actor.
func WithPublicKeyPem ¶
WithPublicKeyPem sets the 'publicKeyPem' property on the public key.
func WithPublishedTime ¶
WithPublishedTime sets the 'publishedTime' property on the object.
func WithResult ¶
func WithResult(result *ObjectProperty) Opt
WithResult sets the 'result' property on the activity.
func WithShares ¶ added in v0.1.2
WithShares sets the 'shares' property on the actor.
func WithStartTime ¶
WithStartTime sets the 'startTime' property on the object.
func WithTag ¶ added in v1.0.0
func WithTag(tag *TagProperty) Opt
WithTag sets the 'tag' property on the object.
func WithTarget ¶
func WithTarget(target *ObjectProperty) Opt
WithTarget sets the 'target' property on the activity.
func WithTotalItems ¶
WithTotalItems sets the 'totalItems' property on the collection or ordered collection.
func WithWitnesses ¶
WithWitnesses sets the 'witnesses' property on the actor.
func WithWitnessing ¶
WithWitnessing sets the 'witnessing' property on the actor.
type Options ¶
type Options struct { Context []Context ID *url.URL URL []*url.URL To []*url.URL Published *time.Time StartTime *time.Time EndTime *time.Time Types []Type CID string InReplyTo *url.URL Attachment []*ObjectProperty AttributedTo *url.URL Generator string Tag []*TagProperty Link *LinkType ObjectPropertyOptions CollectionOptions ActivityOptions ActorOptions PublicKeyOptions AnchorEventOptions }
Options holds all of the options for building an ActivityPub object.
func NewOptions ¶
NewOptions returns an Options struct which is populated with the provided options.
type OrderedCollectionPageType ¶
type OrderedCollectionPageType struct { *OrderedCollectionType // contains filtered or unexported fields }
OrderedCollectionPageType defines a "OrderedCollectionPage" type.
func NewOrderedCollectionPage ¶
func NewOrderedCollectionPage(items []*ObjectProperty, opts ...Opt) *OrderedCollectionPageType
NewOrderedCollectionPage returns a new ordered collection page.
func (*OrderedCollectionPageType) MarshalJSON ¶
func (t *OrderedCollectionPageType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the collection page.
func (*OrderedCollectionPageType) Next ¶
func (t *OrderedCollectionPageType) Next() *url.URL
Next return the URL that may be used to retrieve the next page.
func (*OrderedCollectionPageType) PartOf ¶
func (t *OrderedCollectionPageType) PartOf() *url.URL
PartOf return the URL of the collection of which this page is a part.
func (*OrderedCollectionPageType) Prev ¶
func (t *OrderedCollectionPageType) Prev() *url.URL
Prev return the URL that may be used to retrieve the previous page.
func (*OrderedCollectionPageType) UnmarshalJSON ¶
func (t *OrderedCollectionPageType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the collection page.
type OrderedCollectionType ¶
type OrderedCollectionType struct { *CollectionType // contains filtered or unexported fields }
OrderedCollectionType defines an "OrderedCollection" type.
func NewOrderedCollection ¶
func NewOrderedCollection(items []*ObjectProperty, opts ...Opt) *OrderedCollectionType
NewOrderedCollection returns a new ordered collection.
func (*OrderedCollectionType) Items ¶
func (t *OrderedCollectionType) Items() []*ObjectProperty
Items returns the items in the ordered collection.
func (*OrderedCollectionType) MarshalJSON ¶
func (t *OrderedCollectionType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the ordered collection.
func (*OrderedCollectionType) UnmarshalJSON ¶
func (t *OrderedCollectionType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the ordered collection.
type PublicKeyOptions ¶
PublicKeyOptions holds the options for a Public Key.
type PublicKeyType ¶
type PublicKeyType struct {
// contains filtered or unexported fields
}
PublicKeyType defines a public key object.
func NewPublicKey ¶
func NewPublicKey(opts ...Opt) *PublicKeyType
NewPublicKey returns a new public key object.
func (*PublicKeyType) MarshalJSON ¶ added in v1.0.0
func (t *PublicKeyType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the object to JSON.
func (*PublicKeyType) Owner ¶
func (t *PublicKeyType) Owner() *url.URL
Owner returns the owner of the key.
func (*PublicKeyType) PublicKeyPem ¶
func (t *PublicKeyType) PublicKeyPem() string
PublicKeyPem returns the public key in PEM format.
func (*PublicKeyType) UnmarshalJSON ¶ added in v1.0.0
func (t *PublicKeyType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the object from JSON.
type Relationship ¶ added in v1.0.0
type Relationship []string
Relationship holds the relationship of the Link.
func (Relationship) Is ¶ added in v1.0.0
func (r Relationship) Is(relationship string) bool
Is return true if the given relationship is contained.
type TagProperty ¶ added in v1.0.0
type TagProperty struct {
// contains filtered or unexported fields
}
TagProperty defines the 'tag' property.
func NewTagProperty ¶ added in v1.0.0
func NewTagProperty(opts ...Opt) *TagProperty
NewTagProperty returns a new Tag property.
func (*TagProperty) Link ¶ added in v1.0.0
func (p *TagProperty) Link() *LinkType
Link returns the link of the tag property. Nil is returned if the tag is not a Link type.
func (*TagProperty) MarshalJSON ¶ added in v1.0.0
func (p *TagProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the 'tag' property.
func (*TagProperty) Object ¶ added in v1.0.0
func (p *TagProperty) Object() *ObjectType
Object returns the object of the tag property. Nil is returned if the tag is not an Object type.
func (*TagProperty) Type ¶ added in v1.0.0
func (p *TagProperty) Type() *TypeProperty
Type returns the type of the tag property.
func (*TagProperty) UnmarshalJSON ¶ added in v1.0.0
func (p *TagProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the 'tag' property.
type Type ¶
type Type string
Type indicates the type of the object.
const ( // TypeCollection specifies the 'Collection' object type. TypeCollection Type = "Collection" // TypeOrderedCollection specifies the 'OrderedCollection' object type. TypeOrderedCollection Type = "OrderedCollection" // TypeCollectionPage specifies the 'CollectionPage' object type. TypeCollectionPage Type = "CollectionPage" // TypeOrderedCollectionPage specifies the 'OrderedCollectionPage' object type. TypeOrderedCollectionPage Type = "OrderedCollectionPage" // TypeService specifies the 'Service' actor type. TypeService Type = "Service" // TypeCreate specifies the 'Create' activity type. TypeCreate Type = "Create" // TypeAnnounce specifies the 'Announce' activity type. TypeAnnounce Type = "Announce" // TypeFollow specifies the 'Follow' activity type. TypeFollow Type = "Follow" // TypeAccept specifies the 'Accept' activity type. TypeAccept Type = "Accept" // TypeReject specifies the 'Reject' activity type. TypeReject Type = "Reject" // TypeLike specifies the 'Like' activity type. TypeLike Type = "Like" // TypeInvite specifies the 'Invite' activity type. TypeInvite Type = "Invite" // TypeLink specifies the 'Link' object type. TypeLink Type = "Link" // TypeVerifiableCredential specifies the "VerifiableCredential" object type. TypeVerifiableCredential Type = "VerifiableCredential" //nolint:gosec // TypeAnchorEvent specifies the "AnchorEvent" object type. TypeAnchorEvent Type = "AnchorEvent" // TypeAnchorReceipt specifies the "AnchorReceipt" object type. TypeAnchorReceipt Type = "AnchorReceipt" // TypeOffer specifies the "Offer" activity type. TypeOffer Type = "Offer" // TypeUndo specifies the "Undo" activity type. TypeUndo Type = "Undo" )
type TypeProperty ¶
type TypeProperty struct {
// contains filtered or unexported fields
}
TypeProperty defines a 'type' property on an abject which can hold one or more types.
func NewTypeProperty ¶
func NewTypeProperty(t ...Type) *TypeProperty
NewTypeProperty returns a new 'type' property. Nil is returned if no types were provided.
func (*TypeProperty) Is ¶
func (p *TypeProperty) Is(types ...Type) bool
Is returns true if the property has all of the given types.
func (*TypeProperty) IsActivity ¶ added in v1.0.0
func (p *TypeProperty) IsActivity() bool
IsActivity returns true if the type is an ActivityPub Activity.
func (*TypeProperty) IsAny ¶
func (p *TypeProperty) IsAny(types ...Type) bool
IsAny returns true if the property has any of the given types.
func (*TypeProperty) MarshalJSON ¶
func (p *TypeProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the type property.
func (*TypeProperty) String ¶
func (p *TypeProperty) String() string
String returns the string representation of the type property.
func (*TypeProperty) UnmarshalJSON ¶
func (p *TypeProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the type property.
type URLCollectionProperty ¶
type URLCollectionProperty struct {
// contains filtered or unexported fields
}
URLCollectionProperty contains a collection of URLs.
func NewURLCollectionProperty ¶
func NewURLCollectionProperty(urls ...*url.URL) *URLCollectionProperty
NewURLCollectionProperty returns a new URL collection property. Nil is returned if no URLs were provided.
func (*URLCollectionProperty) MarshalJSON ¶
func (p *URLCollectionProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the URL collection.
func (*URLCollectionProperty) URLs ¶
func (p *URLCollectionProperty) URLs() []*url.URL
URLs returns the URLs.
func (*URLCollectionProperty) UnmarshalJSON ¶
func (p *URLCollectionProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the URL collection.
type URLProperty ¶
type URLProperty struct {
// contains filtered or unexported fields
}
URLProperty holds a URL.
func NewURLProperty ¶
func NewURLProperty(u *url.URL) *URLProperty
NewURLProperty returns a new URL property with the given URL. Nil is returned if the provided URL is nil.
func (*URLProperty) MarshalJSON ¶
func (p *URLProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshals the URL property.
func (*URLProperty) String ¶
func (p *URLProperty) String() string
String returns the string representation of the URL.
func (*URLProperty) UnmarshalJSON ¶
func (p *URLProperty) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the URL property.
type Urls ¶ added in v0.1.1
Urls holds a collection of URLs.
func (Urls) Contains ¶ added in v0.1.1
Contains returns true if the collection of URLs contains the given URLs.