astreams

package module
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: AGPL-3.0 Imports: 9 Imported by: 1

README ΒΆ

astreams

A hand-crafted implementation of the Activity Streams 2.0 specification in Go, especially suitable for projects implementing ActivityPub.

πŸš€ Quick Start

Basic Usage
package main

import (
    "encoding/json"
    "fmt"

    "github.com/MatejLach/astreams"
)

func main() {
    // Decode a Note object
    noteJSON := `{
        "type": "Note",
        "content": "Hello, world!",
        "published": "2023-01-01T00:00:00Z"
    }`

    var note astreams.Note
    err := json.Unmarshal([]byte(noteJSON), &note)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Note content: %s\n", note.Content)

    // Encode it back to JSON
    encodedNote, err := json.Marshal(&note)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(encodedNote))
}

πŸ“š Core Types

Base Types
  • Object - The base ActivityStreams object type
  • Link - The base Link type
  • Actor - Actor types (Person, Organization, etc.)
  • Activity - Activity types (Create, Like, Follow, etc.)
  • IntransitiveActivity - Intransitive activities (Arrive, Travel, etc.)
Collections
  • Collection - Standard collection
  • CollectionPage - Paginated collection
  • OrderedCollection - Ordered collection
  • OrderedCollectionPage - Paginated ordered collection
Special Types
  • ObjectOrLink - Slice that can contain any ActivityStreams object or link
  • ObjectOrLinkOrString - Can hold objects/links or string URLs
  • Icons - Icon representation supporting both URL and Object forms
  • Location - Geographic location data

πŸ”§ Working with Objects

Decoding
// Decode any ActivityStreams object using the generic decoder
func decodeObject(jsonData []byte) (astreams.ObjectLinker, error) {
    var obj astreams.ObjectOrLink
    err := json.Unmarshal(jsonData, &obj)
    if err != nil {
        return nil, err
    }

    if len(obj) > 0 {
        return obj[0], nil
    }
    return nil, errors.New("empty object")
}

// Decode specific types
func decodeNote(jsonData []byte) (*astreams.Note, error) {
    var note astreams.Note
    err := json.Unmarshal(jsonData, &note)
    return &note, err
}
Encoding
// Encode any ActivityStreams object
func encodeObject(obj astreams.ObjectLinker) ([]byte, error) {
    return json.Marshal(obj)
}

// Using the generic encoder
func encodeGeneric[T astreams.ActivityStreamer](toEncode T) ([]byte, error) {
    return astreams.EncodeJSON(toEncode)
}

πŸ“¦ Working with Collections

πŸ“€ Heterogeneous slices

Slices can contain any mix of Object or Link (sub)types:

// ObjectOrLink handles heterogeneous arrays
var items astreams.ObjectOrLink
items = append(items, astreams.Note{Content: "Hello"})
items = append(items, astreams.Person{Name: "Alice"})

jsonBytes, err := json.Marshal(items)
// Results in JSON array with mixed types
// Create and populate a heterogeneous collection
var items astreams.ObjectOrLink

// Add different types of objects
note := astreams.Note{Content: "Hello"}
person := astreams.Person{Name: "Alice"}

items = append(items, note)
items = append(items, person)

// Encode the collection
jsonBytes, err := json.Marshal(items)
Collections with Pagination
// Create a Collection
collection := astreams.Collection{
    TotalItems: 100,
    Items: &astreams.ObjectOrLinkOrString{
        Target: astreams.ObjectOrLink{
            astreams.Note{Content: "First note"},
            astreams.Note{Content: "Second note"},
        },
    },
}

πŸ”„ Generic Helper Functions

DecodeJSON
// Decode any valid ActivityStreams object
note, err := astreams.DecodeJSON[astreams.Note](strings.NewReader(noteJSON))
if err != nil {
    // handle error
}

// Works with any AS type
person, err := astreams.DecodeJSON[astreams.Person](strings.NewReader(personJSON))
activity, err := astreams.DecodeJSON[astreams.Create](strings.NewReader(activityJSON))
EncodeJSON
// Generic encoder for any valid ActivityStreams object
note := astreams.Note{Content: "Hello"}
bytes, err := astreams.EncodeJSON(note)
if err != nil {
    // handle error
}

πŸ“‘ Working with Actors

Person Example
person := astreams.Person{
    ID:                "https://example.com/users/alice",
    Type:              "Person",
    Name:              "Alice Smith",
    PreferredUsername: "alice",
    Summary:           "A person on the web",
    Inbox: &astreams.StringWithOrderedCollection{
        URL: "https://example.com/users/alice/inbox",
    },
    Outbox: &astreams.StringWithOrderedCollection{
        URL: "https://example.com/users/alice/outbox",
    },
}
Actor Collections
// Create a followers collection
followers := astreams.Collection{
    TotalItems: 42,
    First: &astreams.StringWithCollectionPage{
        CollectionPage: astreams.CollectionPage{
            // pagination details
        },
        URL: "https://example.com/users/alice/followers?page=1",
    },
}

πŸ“ Working with Activities

Create Activity Example
createActivity := astreams.Create{
    Type: "Create",
    Actor: &astreams.ObjectOrLinkOrString{
        Target: astreams.ObjectOrLink{
            astreams.Person{
                ID:   "https://example.com/users/alice",
                Name: "Alice Smith",
            },
        },
    },
    ActivityObject: &astreams.ObjectOrLinkOrString{
        Target: astreams.ObjectOrLink{
            astreams.Note{
                Content: "Hello, world!",
                Published: &time.Now(),
            },
        },
    },
}

πŸ” Type Checking and Conversion

Using ConcreteType
func processObject(obj astreams.ObjectLinker) {
    reflectType, asType := astreams.ConcreteType(obj)
    fmt.Printf("Reflection type: %s, AS type: %s\n", reflectType, asType)

    switch asType {
    case "Note":
        if note, ok := obj.(astreams.Note); ok {
            // Handle Note
        }
    case "Person":
        if person, ok := obj.(astreams.Person); ok {
            // Handle Person
        }
    }
}
Type Assertions
// Safe type assertions
func asNote(obj astreams.ObjectLinker) (*astreams.Note, bool) {
    if n, ok := obj.(astreams.Note); ok {
        return &n, true
    }
    return nil, false
}

func asPerson(obj astreams.ObjectLinker) (*astreams.Person, bool) {
    if p, ok := obj.(astreams.Person); ok {
        return &p, true
    }
    return nil, false
}
Type Analysis
func decodePayload(jsonData []byte) (astreams.JsonPayload, error) {
    reader := bytes.NewReader(jsonData)
    payloadType, err := astreams.DecodePayloadObjectType(reader)
    if err != nil {
        return payloadType, err
    }

    switch payloadType.Type {
    case "Note":
        // Handle Note
    case "Person":
        // Handle Person
    default:
        // Handle generic object or unknown type
    }

    return payloadType, nil
}

πŸ“‹ Supported Types

Object Types
  • Object, Link
  • Article, Document, Audio, Video, Image
  • Event, Note, Page
  • Collection, CollectionPage
  • OrderedCollection, OrderedCollectionPage
  • Location, Profile, Tombstone
  • Relationship, Question
  • Link
  • Mention, Hashtag, PropertyValue
Actor Types
  • Application, Group, Organization, Person, Service
Activity Types
  • Accept, Add, Announce, Arrive, Block, Create, Delete
  • Dislike, Follow, Flag, Ignore, Invite, Join, Leave
  • Like, Listen, Move, Offer, Read, Reject, Remove
  • TentativeAccept, TentativeReject, Travel, Undo, Update, View

Contributing

Contributions are welcome. If you've found a bug, or have a feature request, don't hesitate to open an issue.

Documentation ΒΆ

Overview ΒΆ

Package astreams implements JSON serialization/deserialization support for the ActivityStreams 2.0 vocabulary. Simply use json.Marshal/json.Unmarshal on AS 2.0 compliant objects to obtain their JSON/Go representation respectively.

Indirect object references such as a link to an outbox collection within an actor profile need to be fetched explicitly and parsed as a separate object.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func ConcreteType ΒΆ

func ConcreteType(t ObjectLinker) (reflectType, astreamsType string)

ConcreteType returns both, the type name obtained using reflection, and the Type property of the Object / Link JSON payload. The object's own Type property is going to be more specific, so use that where useful.

func DecodeJSON ΒΆ added in v0.6.0

func DecodeJSON[T ActivityStreamer](jsonPayload io.Reader) (T, error)

DecodeJSON is the generic unmarshaller for any valid ActivityStreams 2.0 object

func EncodeJSON ΒΆ added in v0.6.0

func EncodeJSON[T ActivityStreamer](toEncode T) ([]byte, error)

EncodeJSON is the generic marshaller for any valid ActivityStreams 2.0 object

Types ΒΆ

type Accept ΒΆ

type Accept = Activity

Extended 'Activity' types

type Activity ΒΆ

type Activity struct {
	Object

	Actor          *ObjectOrLinkOrString `json:"actor,omitempty"`
	ActivityObject *ObjectOrLinkOrString `json:"object,omitempty"` // the 'object' property of Activity
	Instrument     *ObjectOrLinkOrString `json:"instrument,omitempty"`
	Origin         *ObjectOrLinkOrString `json:"origin,omitempty"`
	Result         *ObjectOrLinkOrString `json:"result,omitempty"`
	Target         *ObjectOrLinkOrString `json:"target,omitempty"`
}

type ActivityStreamer ΒΆ added in v0.5.0

ActivityStreamer is a generic type constraint representing all valid Activity Streams 2.0 types

type Actor ΒΆ

type Actor struct {
	Object

	Devices                   *StringWithCollection        `json:"devices,omitempty"`
	Discoverable              *bool                        `json:"discoverable,omitempty"`
	Endpoints                 *Endpoints                   `json:"endpoints,omitempty"`
	Featured                  *StringWithOrderedCollection `json:"featured,omitempty"`
	FeaturedTags              *StringWithCollection        `json:"featuredTags,omitempty"`
	Followers                 *StringWithOrderedCollection `json:"followers,omitempty"`
	Following                 *StringWithOrderedCollection `json:"following,omitempty"`
	Inbox                     *StringWithOrderedCollection `json:"inbox,omitempty"`
	Indexable                 *bool                        `json:"indexable,omitempty"`
	Liked                     *StringWithOrderedCollection `json:"liked,omitempty"`
	ManuallyApprovesFollowers *bool                        `json:"manuallyApprovesFollowers,omitempty"`
	Memorial                  *bool                        `json:"memorial,omitempty"`
	Outbox                    *StringWithOrderedCollection `json:"outbox,omitempty"`
	PreferredUsername         string                       `json:"preferredUsername,omitempty"`
	PublicKey                 *PublicKey                   `json:"publicKey,omitempty"`
	Streams                   *ObjectOrLinkOrString        `json:"streams,omitempty"`
}

type Add ΒΆ

type Add = Activity

type Announce ΒΆ

type Announce = Activity

type Application ΒΆ

type Application = Actor

Extended 'Actor' types

type Arrive ΒΆ

type Arrive = IntransitiveActivity

type Article ΒΆ

type Article = Object

Extended 'Object' types

type Audio ΒΆ

type Audio = Document

type Block ΒΆ

type Block = Ignore

type Collection ΒΆ

type Collection struct {
	Object

	Current    *StringWithCollectionPage `json:"current,omitempty"`
	First      *StringWithCollectionPage `json:"first,omitempty"`
	Items      *ObjectOrLinkOrString     `json:"items,omitempty"`
	Last       *StringWithCollectionPage `json:"last,omitempty"`
	TotalItems int                       `json:"totalItems,omitempty"`
}

func (*Collection) MarshalJSON ΒΆ added in v0.7.0

func (col *Collection) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

type CollectionPage ΒΆ

type CollectionPage struct {
	Collection

	Next   *ObjectOrLinkOrString `json:"next,omitempty"`
	PartOf *ObjectOrLinkOrString `json:"partOf,omitempty"`
	Prev   *ObjectOrLinkOrString `json:"prev,omitempty"`
}

func (*CollectionPage) MarshalJSON ΒΆ added in v0.7.0

func (colp *CollectionPage) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

type Create ΒΆ

type Create = Activity

type Delete ΒΆ

type Delete = Activity

type Dislike ΒΆ

type Dislike = Activity

type Document ΒΆ

type Document = Object

type Endpoints ΒΆ

type Endpoints struct {
	OauthAuthorizationEndpoint string                       `json:"oauthAuthorizationEndpoint,omitempty"`
	OauthTokenEndpoint         string                       `json:"oauthTokenEndpoint,omitempty"`
	ProvideClientKey           string                       `json:"provideClientKey,omitempty"`
	ProxyUrl                   string                       `json:"proxyUrl,omitempty"`
	SharedInbox                *StringWithOrderedCollection `json:"sharedInbox,omitempty"`
	SignClientKey              string                       `json:"signClientKey,omitempty"`
}

type Event ΒΆ

type Event = Object

type Flag ΒΆ

type Flag = Activity

type Follow ΒΆ

type Follow = Activity

type Group ΒΆ

type Group = Actor

type Hashtag ΒΆ

type Hashtag = Link

type Icon ΒΆ

type Icon struct {
	Object

	Height int `json:"height"`
	Width  int `json:"width"`
}

type Icons ΒΆ

type Icons struct {
	Icons []Icon
	URL   string
}

Icons is a type representing the possible ActivityPub icon values

func (*Icons) MarshalJSON ΒΆ

func (ics *Icons) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*Icons) String ΒΆ

func (ics *Icons) String() string

Implements https://golang.org/pkg/fmt/#Stringer

func (*Icons) UnmarshalJSON ΒΆ

func (ics *Icons) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type Ignore ΒΆ

type Ignore = Activity

type Image ΒΆ

type Image struct {
	Document

	Height int `json:"height,omitempty"`
	Width  int `json:"width,omitempty"`
}

type IntransitiveActivity ΒΆ

type IntransitiveActivity struct {
	Object

	Actor      *ObjectOrLinkOrString `json:"actor,omitempty"`
	Instrument *ObjectOrLinkOrString `json:"instrument,omitempty"`
	Origin     *ObjectOrLinkOrString `json:"origin,omitempty"`
	Result     *ObjectOrLinkOrString `json:"result,omitempty"`
	Target     *ObjectOrLinkOrString `json:"target,omitempty"`
}

type Invite ΒΆ

type Invite = Offer

type Join ΒΆ

type Join = Activity

type JsonPayload ΒΆ added in v0.6.0

type JsonPayload struct {
	Type string `json:"type"`
}

func DecodePayloadObjectType ΒΆ added in v0.6.0

func DecodePayloadObjectType(payload io.Reader) (JsonPayload, error)

DecodePayloadObjectType can be used to check the specific type of unknown JSON payload

payloadMeta, err := DecodePayloadObjectType(payload)
if err != nil {
	//
}

switch payloadMeta.Type {
case "Note":
	var note Note
	err = json.Unmarshal([]byte(tc), &note)
	if err != nil {
		//
	}
case "Offer":
	var offer Offer
	err = json.Unmarshal([]byte(tc), &offer)
	if err != nil {
		//
	}
case "Person":
	var person Person
	err = json.Unmarshal([]byte(tc), &person)
	if err != nil {
		//
	}

	if person.Name == "" {
		//
	}
default:
	var obj ObjectOrLinkOrString
	err = json.Unmarshal([]byte(tc), &obj)
	if err != nil {
		//
	}
}

type Leave ΒΆ

type Leave = Activity

type Like ΒΆ

type Like = Activity
type Link struct {
	ASContext  any                   `json:"@context,omitempty"`
	ASLanguage string                `json:"@language,omitempty"`
	Height     int                   `json:"height,omitempty"`
	Href       string                `json:"href,omitempty"`
	Hreflang   string                `json:"hreflang,omitempty"`
	MediaType  string                `json:"mediaType,omitempty"`
	Name       string                `json:"name,omitempty"`
	NameMap    map[string]string     `json:"nameMap,omitempty"`
	Preview    *ObjectOrLinkOrString `json:"preview,omitempty"`
	Published  *time.Time            `json:"published,omitempty"`
	Rel        []string              `json:"rel,omitempty"`
	Type       string                `json:"type"`
	Value      string                `json:"value,omitempty"`
	Width      int                   `json:"width,omitempty"`
}

Link represents the base ActivityStreams Link and all of its properties Other Link types extend it

func (l Link) GetLink() *Link

func (Link) GetObject ΒΆ

func (l Link) GetObject() *Object
func (l Link) IsLink() bool

func (Link) IsObject ΒΆ

func (l Link) IsObject() bool

Implements 'ObjectLinker' interface for 'Link'

type Listen ΒΆ

type Listen = Activity

type Location ΒΆ

type Location struct {
	Object

	Altitude  int     `json:"altitude,omitempty"`
	Latitude  float32 `json:"latitude,omitempty"`
	Longitude float32 `json:"longitude,omitempty"`
	Units     string  `json:"units,omitempty"`
}

func (*Location) String ΒΆ

func (loc *Location) String() string

Implements https://golang.org/pkg/fmt/#Stringer

type Mention ΒΆ

type Mention = Link

Extended 'Link' types

type Move ΒΆ

type Move = Activity

type Note ΒΆ

type Note = Object

type Object ΒΆ

type Object struct {
	AlsoKnownAs  *ObjectOrLinkOrString `json:"alsoKnownAs,omitempty"`
	ASContext    any                   `json:"@context,omitempty"`
	ASLanguage   string                `json:"@language,omitempty"`
	AtID         string                `json:"@id,omitempty"`
	AtType       string                `json:"@type,omitempty"`
	Attachment   *ObjectOrLinkOrString `json:"attachment,omitempty"`
	AttributedTo *ObjectOrLinkOrString `json:"attributedTo,omitempty"`
	Audience     *ObjectOrLinkOrString `json:"audience,omitempty"`
	Bcc          *ObjectOrLinkOrString `json:"bcc,omitempty"`
	Bto          *ObjectOrLinkOrString `json:"bto,omitempty"`
	Cc           *ObjectOrLinkOrString `json:"cc,omitempty"`
	Content      string                `json:"content,omitempty"` // needs to be parsed safely ie by https://golang.org/pkg/html/template
	ContentMap   map[string]string     `json:"contentMap,omitempty"`
	Context      *ObjectOrLinkOrString `json:"context,omitempty"`
	Conversation string                `json:"conversation,omitempty"`
	Duration     string                `json:"duration,omitempty"` // xsd:duration
	EndTime      *time.Time            `json:"endTime,omitempty"`
	Generator    *ObjectOrLinkOrString `json:"generator,omitempty"`
	Icon         *ObjectOrLinkOrString `json:"icon,omitempty"`
	ID           string                `json:"id,omitempty"`
	Image        *ObjectOrLinkOrString `json:"image,omitempty"`
	InReplyTo    *ObjectOrLinkOrString `json:"inReplyTo,omitempty"`
	Likes        *ObjectOrLinkOrString `json:"likes,omitempty"`
	Location     *ObjectOrLinkOrString `json:"location,omitempty"`
	MediaType    string                `json:"mediaType,omitempty"`
	MovedTo      *ObjectOrLinkOrString `json:"movedTo,omitempty"`
	Name         string                `json:"name,omitempty"`
	NameMap      map[string]string     `json:"nameMap,omitempty"`
	Preview      *ObjectOrLinkOrString `json:"preview,omitempty"`
	Published    *time.Time            `json:"published,omitempty"`
	Replies      *OrderedCollection    `json:"replies,omitempty"`
	Schema       string                `json:"schema,omitempty"`
	Sensitive    bool                  `json:"sensitive,omitempty"`
	Shares       *ObjectOrLinkOrString `json:"shares,omitempty"`
	Source       *ObjectOrLinkOrString `json:"source,omitempty"`
	StartTime    *time.Time            `json:"startTime,omitempty"`
	Summary      string                `json:"summary,omitempty"`
	SummaryMap   map[string]string     `json:"summaryMap,omitempty"`
	Tag          *ObjectOrLinkOrString `json:"tag,omitempty"`
	To           *ObjectOrLinkOrString `json:"to,omitempty"`
	Type         string                `json:"type"`
	Updated      *time.Time            `json:"updated,omitempty"`
	URL          *ObjectOrLinkOrString `json:"url,omitempty"`
}

Object represents the base ActivityStreams Object and all of its properties Most of the other types extend Object

func (o Object) GetLink() *Link

func (Object) GetObject ΒΆ

func (o Object) GetObject() *Object
func (o Object) IsLink() bool

func (Object) IsObject ΒΆ

func (o Object) IsObject() bool

Implements 'ObjectLinker' interface for 'Object'

type ObjectLinker ΒΆ added in v0.6.0

type ObjectLinker interface {
	IsObject() bool
	IsLink() bool
	GetObject() *Object
	GetLink() *Link
}

ObjectLinker can be either a (sub)type of 'Object' or a (sub)type of 'Link'

type ObjectOrLink []ObjectLinker

ObjectOrLink is a wrapper type that represents any valid ActivityStreams 2.0 object or link Single objects are still presented as slices, but with a single element

func (*ObjectOrLink) MarshalJSON ΒΆ

func (ol *ObjectOrLink) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*ObjectOrLink) UnmarshalJSON ΒΆ

func (ol *ObjectOrLink) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type ObjectOrLinkOrString ΒΆ

type ObjectOrLinkOrString struct {
	Target ObjectOrLink
	URL    []string
}

ObjectOrLinkOrString is a type that can either represent simple string URL(s) or an Object/Link slice

func (*ObjectOrLinkOrString) MarshalJSON ΒΆ

func (ols *ObjectOrLinkOrString) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*ObjectOrLinkOrString) String ΒΆ

func (ols *ObjectOrLinkOrString) String() string

Implements https://golang.org/pkg/fmt/#Stringer

func (*ObjectOrLinkOrString) UnmarshalJSON ΒΆ

func (ols *ObjectOrLinkOrString) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type Offer ΒΆ

type Offer = Activity

type OrderedCollection ΒΆ

type OrderedCollection struct {
	Object

	Current      *StringWithOrderedCollectionPage `json:"current,omitempty"`
	First        *StringWithOrderedCollectionPage `json:"first,omitempty"`
	Last         *StringWithOrderedCollectionPage `json:"last,omitempty"`
	OrderedItems *ObjectOrLinkOrString            `json:"orderedItems"`
	TotalItems   int                              `json:"totalItems"`
}

OrderedCollection implements https://golang.org/pkg/sort/#Interface

func (OrderedCollection) Len ΒΆ

func (oc OrderedCollection) Len() int

func (OrderedCollection) Less ΒΆ

func (oc OrderedCollection) Less(i, j int) bool

func (*OrderedCollection) MarshalJSON ΒΆ added in v0.7.0

func (oc *OrderedCollection) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (OrderedCollection) SortByUpdated ΒΆ

func (oc OrderedCollection) SortByUpdated()

SortByUpdated sorts OrderedCollection objects by Updated rather than Published date

func (*OrderedCollection) String ΒΆ

func (oc *OrderedCollection) String() string

Implements https://golang.org/pkg/fmt/#Stringer

func (OrderedCollection) Swap ΒΆ

func (oc OrderedCollection) Swap(i, j int)

type OrderedCollectionPage ΒΆ

type OrderedCollectionPage struct {
	OrderedCollection

	Next       *ObjectOrLinkOrString `json:"next,omitempty"`
	PartOf     *ObjectOrLinkOrString `json:"partOf,omitempty"`
	Prev       *ObjectOrLinkOrString `json:"prev,omitempty"`
	StartIndex uint                  `json:"startIndex,omitempty"`
}

OrderedCollectionPage implements https://golang.org/pkg/sort/#Interface

func (*OrderedCollectionPage) MarshalJSON ΒΆ added in v0.7.0

func (ocolp *OrderedCollectionPage) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

type Organization ΒΆ

type Organization = Actor

type Page ΒΆ

type Page = Document

type Person ΒΆ

type Person = Actor

type Place ΒΆ

type Place struct {
	Location

	Accuracy float32 `json:"accuracy,omitempty"`
	Radius   float32 `json:"radius,omitempty"`
}

type Profile ΒΆ

type Profile struct {
	Object

	Describes ObjectOrLinkOrString `json:"describes,omitempty"`
}

type PropertyValue ΒΆ

type PropertyValue = Link

type PublicKey ΒΆ

type PublicKey struct {
	ID           string `json:"id"`
	Owner        string `json:"owner"`
	PublicKeyPem string `json:"publicKeyPem"`
}

type Question ΒΆ

type Question struct {
	IntransitiveActivity

	// only OneOf or AnyOf can be set, not both
	AnyOf  *ObjectOrLinkOrString `json:"anyOf,omitempty"`
	Closed *time.Time            `json:"closed,omitempty"`
	OneOf  *ObjectOrLinkOrString `json:"oneOf,omitempty"`
}

type Read ΒΆ

type Read = Activity

type Reject ΒΆ

type Reject = Activity

type Relationship ΒΆ

type Relationship struct {
	Object

	Relationship       string                `json:"relationship,omitempty"`
	RelationshipObject *ObjectOrLinkOrString `json:"object,omitempty"`
	Subject            *ObjectOrLinkOrString `json:"subject,omitempty"`
}

type Remove ΒΆ

type Remove = Activity

type Service ΒΆ

type Service = Actor

type StringWithCollection ΒΆ

type StringWithCollection struct {
	Collection Collection
	URL        string
}

StringWithCollection can store a string URL pointing to a Collection, which can itself be stored in the struct

func (*StringWithCollection) MarshalJSON ΒΆ

func (sc *StringWithCollection) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*StringWithCollection) String ΒΆ

func (sc *StringWithCollection) String() string

Implements https://golang.org/pkg/fmt/#Stringer

func (*StringWithCollection) UnmarshalJSON ΒΆ

func (sc *StringWithCollection) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type StringWithCollectionPage ΒΆ added in v0.8.0

type StringWithCollectionPage struct {
	CollectionPage CollectionPage
	URL            string
}

StringWithCollectionPage can store a string URL pointing to a CollectionPage, which can itself be stored in the struct

func (*StringWithCollectionPage) MarshalJSON ΒΆ added in v0.10.0

func (scp *StringWithCollectionPage) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*StringWithCollectionPage) UnmarshalJSON ΒΆ added in v0.10.0

func (scp *StringWithCollectionPage) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type StringWithOrderedCollection ΒΆ

type StringWithOrderedCollection struct {
	OrdCollection OrderedCollection
	URL           string
}

StringWithOrderedCollection can store a string URL pointing to an OrderedCollection, which can itself be stored in the struct

func (*StringWithOrderedCollection) MarshalJSON ΒΆ

func (soc *StringWithOrderedCollection) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*StringWithOrderedCollection) String ΒΆ

func (soc *StringWithOrderedCollection) String() string

Implements https://golang.org/pkg/fmt/#Stringer

func (*StringWithOrderedCollection) UnmarshalJSON ΒΆ

func (soc *StringWithOrderedCollection) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type StringWithOrderedCollectionPage ΒΆ added in v0.8.0

type StringWithOrderedCollectionPage struct {
	OrdCollectionPage OrderedCollectionPage
	URL               string
}

StringWithOrderedCollectionPage can store a string URL pointing to an OrderedCollectionPage, which can itself be stored in the struct

func (*StringWithOrderedCollectionPage) MarshalJSON ΒΆ added in v0.10.0

func (socp *StringWithOrderedCollectionPage) MarshalJSON() ([]byte, error)

Implements https://golang.org/pkg/encoding/json/#Marshal

func (*StringWithOrderedCollectionPage) UnmarshalJSON ΒΆ added in v0.10.0

func (socp *StringWithOrderedCollectionPage) UnmarshalJSON(data []byte) error

Implements https://golang.org/pkg/encoding/json/#Unmarshaler

type TentativeAccept ΒΆ

type TentativeAccept = Accept

type TentativeReject ΒΆ

type TentativeReject = Reject

type Tombstone ΒΆ

type Tombstone struct {
	Object

	Deleted    *time.Time `json:"deleted,omitempty"`
	FormerType string     `json:"formerType,omitempty"`
}

type Travel ΒΆ

type Travel = IntransitiveActivity

type Undo ΒΆ

type Undo = Activity

type Update ΒΆ

type Update = Activity

type Video ΒΆ

type Video = Document

type View ΒΆ

type View = Activity

Jump to

Keyboard shortcuts

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