resthandler

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

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}"
	// AcceptListPath specifies the endpoint to manage an "accept list" for a service.
	AcceptListPath = "/acceptlist"
)
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 AcceptListReader

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

AcceptListReader implements a REST handler to read a service's "accept list".

func NewAcceptListReader

func NewAcceptListReader(cfg *Config, mgr acceptListMgr) *AcceptListReader

NewAcceptListReader returns a new REST handler to read a service's "accept list".

func (*AcceptListReader) Handler

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 (*AcceptListReader) Method

func (h *AcceptListReader) Method() string

Method returns the HTTP method, which is always GET.

func (*AcceptListReader) Path

func (h *AcceptListReader) Path() string

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

type AcceptListWriter

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

AcceptListWriter implements a REST handler to update a service's "accept list".

func NewAcceptListWriter

func NewAcceptListWriter(cfg *Config, mgr acceptListMgr) *AcceptListWriter

NewAcceptListWriter returns a new REST handler to update the "accept list".

func (*AcceptListWriter) Handler

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 (*AcceptListWriter) Method

func (h *AcceptListWriter) Method() string

Method returns the HTTP method, which is always POST.

func (*AcceptListWriter) Path

func (h *AcceptListWriter) Path() string

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

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,
	sortOrder spi.SortOrder, tm authTokenManager) *Activities

NewActivities returns a new activities REST handler.

func NewInbox

func NewInbox(cfg *Config, activityStore spi.Store, verifier signatureVerifier,
	sortOrder spi.SortOrder, tm authTokenManager) *Activities

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

func NewLikes

func NewLikes(cfg *Config, activityStore spi.Store, verifier signatureVerifier,
	sortOrder spi.SortOrder, tm authTokenManager) *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,
	sortOrder spi.SortOrder, tm authTokenManager) *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

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

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

func NewActivity

func NewActivity(cfg *Config, activityStore spi.Store, verifier signatureVerifier,
	sortOrder spi.SortOrder, tm authTokenManager) *Activity

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

func (Activity) Handler

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

func (h Activity) Method() string

Method returns the HTTP method, which is always GET.

func (Activity) Params

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

Params returns the accepted parameters.

func (Activity) Path

func (h Activity) Path() string

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

type AuthHandler

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

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

NewAuthHandler returns a new authorization handler.

func (*AuthHandler) Authorize

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 {
	BasePath               string
	ObjectIRI              *url.URL
	ServiceEndpointURL     *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, tm authTokenManager) *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

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,
	sortOrder spi.SortOrder, tm authTokenManager) *ReadOutbox

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

func (ReadOutbox) Handler

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

func (h ReadOutbox) Method() string

Method returns the HTTP method, which is always GET.

func (ReadOutbox) Params

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

Params returns the accepted parameters.

func (ReadOutbox) Path

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, tm authTokenManager) *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, tm authTokenManager) *Reference

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

func NewLiked

func NewLiked(cfg *Config, activityStore spi.Store, verifier signatureVerifier, tm authTokenManager) *Reference

NewLiked returns a new 'liked' REST handler that retrieves the references of all the anchor events that this service liked.

func NewReference

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

NewReference returns a new reference REST handler.

func NewWitnesses

func NewWitnesses(cfg *Config, activityStore spi.Store, verifier signatureVerifier, tm authTokenManager) *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, tm authTokenManager) *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,
	tm authTokenManager) *Services

NewPublicKeys returns a new public keys REST handler.

func NewServices

func NewServices(cfg *Config, activityStore spi.Store, publicKey *vocab.PublicKeyType,
	tm authTokenManager) *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