resthandler

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// PublicKeysPath specifies the service's "keys" endpoint.
	PublicKeysPath = "/keys/{id}"
	// FollowersPath specifies the service's 'followers' endpoint.
	FollowersPath = "/followers"
	// FollowingPath specifies the service's 'following' endpoint.
	FollowingPath = "/following"
	// OutboxPath specifies the service's 'outbox' endpoint.
	OutboxPath = "/outbox"
	// InboxPath specifies the service's 'inbox' endpoint.
	InboxPath = "/inbox"
	// WitnessesPath specifies the service's 'witnesses' endpoint.
	WitnessesPath = "/witnesses"
	// WitnessingPath specifies the service's 'witnessing' endpoint.
	WitnessingPath = "/witnessing"
	// LikedPath specifies the service's 'liked' endpoint.
	LikedPath = "/liked"
	// SharesPath specifies the object's 'shares' endpoint.
	SharesPath = "/shares"
	// LikesPath specifies the object's 'likes' endpoint.
	LikesPath = "/likes"
	// ActivitiesPath specifies the object's 'activities' endpoint.
	ActivitiesPath = "/activities/{id}"
)
View Source
const MainKeyID = "main-key"

MainKeyID is the ID of the service's public key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activities

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

Activities implements a REST handler that retrieves activities.

func NewActivities

func NewActivities(path string, refType spi.ReferenceType, cfg *Config, activityStore spi.Store,
	getObjectIRI getObjectIRIFunc, getID getIDFunc, verifier signatureVerifier) *Activities

NewActivities returns a new activities REST handler.

func NewInbox

func NewInbox(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Activities

NewInbox returns a new 'inbox' REST handler that retrieves a service's inbox.

func NewLiked

func NewLiked(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Activities

NewLiked returns a new 'liked' REST handler that retrieves a service's 'Like' activities, i.e. the Like activities that were posted by the given service.

func NewLikes

func NewLikes(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Activities

NewLikes returns a new 'likes' REST handler that retrieves an object's 'Like' activities.

func NewShares

func NewShares(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Activities

NewShares returns a new 'shares' REST handler that retrieves an object's 'Announce' activities.

func (Activities) Handler

func (h Activities) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP GET is requested to the target endpoint. This handler must be registered with an HTTP server.

func (Activities) Method

func (h Activities) Method() string

Method returns the HTTP method, which is always GET.

func (Activities) Params

func (h Activities) Params() map[string]string

Params returns the accepted parameters.

func (Activities) Path

func (h Activities) Path() string

Path returns the base path of the target URL for this handler.

type Activity added in v0.1.1

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

Activity implements a REST handler that retrieves a single activity by ID.

func NewActivity added in v0.1.1

func NewActivity(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Activity

NewActivity returns a new 'activities/{id}' REST handler that retrieves a single activity by ID.

func (Activity) Handler added in v0.1.1

func (h Activity) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP GET is requested to the target endpoint. This handler must be registered with an HTTP server.

func (Activity) Method added in v0.1.1

func (h Activity) Method() string

Method returns the HTTP method, which is always GET.

func (Activity) Params added in v0.1.1

func (h Activity) Params() map[string]string

Params returns the accepted parameters.

func (Activity) Path added in v0.1.1

func (h Activity) Path() string

Path returns the base path of the target URL for this handler.

type AuthHandler added in v0.1.2

type AuthHandler struct {
	*Config
	// contains filtered or unexported fields
}

AuthHandler handles authorization of an HTTP request. Both bearer token and HTTP signature authorization are performed.

func NewAuthHandler added in v0.1.2

func NewAuthHandler(cfg *Config, endpoint, method string, s store.Store, verifier signatureVerifier,
	authorizeActor authorizeActorFunc) *AuthHandler

NewAuthHandler returns a new authorization handler.

func (*AuthHandler) Authorize added in v0.1.2

func (h *AuthHandler) Authorize(req *http.Request) (bool, *url.URL, error)

Authorize authorizes the request, first checking the required bearer token and then, if the bearer token was not provided, the HTTP signature.

type Config

type Config struct {
	auth.Config

	BasePath               string
	ObjectIRI              *url.URL
	PageSize               int
	VerifyActorInSignature bool
}

Config contains configuration parameters for the handler.

type Outbox

type Outbox struct {
	*Config
	*AuthHandler
	// contains filtered or unexported fields
}

Outbox implements a REST handler for posts to a service's outbox.

func NewPostOutbox

func NewPostOutbox(cfg *Config, ob outbox, s store.Store, verifier signatureVerifier) *Outbox

NewPostOutbox returns a new REST handler to post activities to the outbox.

func (*Outbox) Handler

func (h *Outbox) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP POST is requested to the target endpoint. This handler must be registered with an HTTP server.

func (*Outbox) Method

func (h *Outbox) Method() string

Method returns the HTTP method, which is always POST.

func (*Outbox) Path

func (h *Outbox) Path() string

Path returns the base path of the target URL for this handler.

type ReadOutbox added in v0.1.1

type ReadOutbox struct {
	*Activities
}

ReadOutbox defines an endpoint that retrieves activities from the outbox. The caller has access to all activities if they are authorized, otherwise only public activities are returned.

func NewOutbox

func NewOutbox(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *ReadOutbox

NewOutbox returns a new 'outbox' REST handler that retrieves a service's outbox.

func (ReadOutbox) Handler added in v0.1.1

func (h ReadOutbox) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP GET is requested to the target endpoint. This handler must be registered with an HTTP server.

func (ReadOutbox) Method added in v0.1.1

func (h ReadOutbox) Method() string

Method returns the HTTP method, which is always GET.

func (ReadOutbox) Params added in v0.1.1

func (h ReadOutbox) Params() map[string]string

Params returns the accepted parameters.

func (ReadOutbox) Path added in v0.1.1

func (h ReadOutbox) Path() string

Path returns the base path of the target URL for this handler.

type Reference

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

Reference implements a REST handler that retrieves references as a collection of IRIs.

func NewFollowers

func NewFollowers(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Reference

NewFollowers returns a new 'followers' REST handler that retrieves a service's list of followers.

func NewFollowing

func NewFollowing(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Reference

NewFollowing returns a new 'following' REST handler that retrieves a service's list of following.

func NewReference

func NewReference(path string, refType spi.ReferenceType, sortOrder spi.SortOrder, ordered bool,
	cfg *Config, activityStore spi.Store, getObjectIRI getObjectIRIFunc, getID getIDFunc,
	verifier signatureVerifier) *Reference

NewReference returns a new reference REST handler.

func NewWitnesses

func NewWitnesses(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Reference

NewWitnesses returns a new 'witnesses' REST handler that retrieves a service's list of witnesses.

func NewWitnessing

func NewWitnessing(cfg *Config, activityStore spi.Store, verifier signatureVerifier) *Reference

NewWitnessing returns a new 'witnessing' REST handler that retrieves collection of the services that the local service is witnessing.

func (Reference) Handler

func (h Reference) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP GET is requested to the target endpoint. This handler must be registered with an HTTP server.

func (Reference) Method

func (h Reference) Method() string

Method returns the HTTP method, which is always GET.

func (Reference) Params

func (h Reference) Params() map[string]string

Params returns the accepted parameters.

func (Reference) Path

func (h Reference) Path() string

Path returns the base path of the target URL for this handler.

type Services

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

Services implements the 'services' REST handler to retrieve a given ActivityPub service (actor).

func NewPublicKeys

func NewPublicKeys(cfg *Config, activityStore spi.Store, publicKey *vocab.PublicKeyType) *Services

NewPublicKeys returns a new public keys REST handler.

func NewServices

func NewServices(cfg *Config, activityStore spi.Store, publicKey *vocab.PublicKeyType) *Services

NewServices returns a new 'services' REST handler.

func (Services) Handler

func (h Services) Handler() common.HTTPRequestHandler

Handler returns the handler that should be invoked when an HTTP GET is requested to the target endpoint. This handler must be registered with an HTTP server.

func (Services) Method

func (h Services) Method() string

Method returns the HTTP method, which is always GET.

func (Services) Params

func (h Services) Params() map[string]string

Params returns the accepted parameters.

func (Services) Path

func (h Services) Path() string

Path returns the base path of the target URL for this handler.

Jump to

Keyboard shortcuts

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