handlers

package module
v0.0.0-...-5e6616a Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 9 Imported by: 1

README

MIT Licensed Build Status Test Coverage Go Report Card

Documentation

Index

Constants

View Source
const (
	Unknown   = CollectionType("")
	Outbox    = CollectionType("outbox")
	Inbox     = CollectionType("inbox")
	Shares    = CollectionType("shares")
	Replies   = CollectionType("replies") // activitystreams
	Following = CollectionType("following")
	Followers = CollectionType("followers")
	Liked     = CollectionType("liked")
	Likes     = CollectionType("likes")
)

Variables

View Source
var RepositoryKey = CtxtKey("__repo")

Functions

func IRIf

func IRIf(i pub.IRI, t CollectionType) pub.IRI

IRIf formats an IRI from an existing IRI and the collection type

func ValidActivityCollection

func ValidActivityCollection(typ CollectionType) bool

ValidActivityCollection shows if the current ActivityPub end-point type is a valid one for handling Activities

func ValidCollection

func ValidCollection(typ CollectionType) bool

func ValidCollectionIRI

func ValidCollectionIRI(i pub.IRI) bool

func ValidObjectCollection

func ValidObjectCollection(typ CollectionType) bool

ValidActivityCollection shows if the current ActivityPub end-point type is a valid one for handling Objects

Types

type ActivityHandlerFn

type ActivityHandlerFn func(CollectionType, *http.Request, storage.Store) (pub.Item, int, error)

ActivityHandlerFn is the type that we're using to represent handlers that process requests containing an ActivityStreams Activity. It needs to implement the http.Handler interface.

It is considered that following the execution of the handler, we return a pair formed of a HTTP status together with

an IRI representing a new Object - in the case of transitive activities that had a side effect, or
an error.

In the case of intransitive activities the iri will always be empty.

func (ActivityHandlerFn) ServeHTTP

func (a ActivityHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for the ActivityHandlerFn type

func (ActivityHandlerFn) Storage

func (a ActivityHandlerFn) Storage(r *http.Request) (storage.Store, error)

func (ActivityHandlerFn) ValidMethod

func (a ActivityHandlerFn) ValidMethod(r *http.Request) bool

ValidMethod validates if the current handler can process the current request

func (ActivityHandlerFn) ValidateRequest

func (a ActivityHandlerFn) ValidateRequest(r *http.Request) (int, error)

ValidateRequest validates if the current handler can process the current request

type CollectionHandlerFn

type CollectionHandlerFn func(CollectionType, *http.Request, storage.ReadStore) (pub.CollectionInterface, error)

CollectionHandlerFn is the type that we're using to represent handlers that will return ActivityStreams Collection or OrderedCollection objects. It needs to implement the http.Handler interface.

func (CollectionHandlerFn) ServeHTTP

func (c CollectionHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for the CollectionHandlerFn type

func (CollectionHandlerFn) Storage

func (CollectionHandlerFn) ValidMethod

func (c CollectionHandlerFn) ValidMethod(r *http.Request) bool

ValidMethod validates if the current handler can process the current request

func (CollectionHandlerFn) ValidateRequest

func (c CollectionHandlerFn) ValidateRequest(r *http.Request) (int, error)

ValidateRequest validates if the current handler can process the current request

type CollectionType

type CollectionType string

CollectionType

func Split

func Split(i pub.IRI) (pub.IRI, CollectionType)

Split returns the base IRI of received i, if i represents an IRI matching collection type t

func (CollectionType) AddTo

func (t CollectionType) AddTo(i pub.Item) (pub.IRI, bool)

AddTo adds collection type IRI on the corresponding property of the i Item

func (CollectionType) IRI

func (t CollectionType) IRI(i pub.Item) pub.IRI

IRI gives us the IRI of the t collection type corresponding to the i Item, or generates a new one if not found.

func (CollectionType) Of

func (t CollectionType) Of(i pub.Item) pub.Item

Of gives us the property of the i Item that corresponds to the t collection type.

func (CollectionType) OfActor

func (t CollectionType) OfActor(i pub.IRI) (pub.IRI, error)

OfActor returns the base IRI of received i, if i represents an IRI matching collection type t

type CollectionTyper

type CollectionTyper interface {
	Type(r *http.Request) CollectionType
}

CollectionTyper allows external packages to tell us which collection the current HTTP request addresses

var Typer CollectionTyper = pathTyper{}

Typer is the static package variable that determines a collection type for a particular request It can be overloaded from outside packages. @TODO(marius): This should be moved as a property on an instantiable package object, instead of keeping it here

type CollectionTypes

type CollectionTypes []CollectionType

CollectionTypes

func (CollectionTypes) Contains

func (t CollectionTypes) Contains(typ CollectionType) bool

func (CollectionTypes) Split

func (t CollectionTypes) Split(i pub.IRI) (pub.IRI, CollectionType)

Split splits the IRI in an actor IRI and its collection if the collection is found in the elements in the t CollectionTypes slice

type CtxtKey

type CtxtKey string

CtxtKey type alias for the key under which we're storing the Collection Storage in the Request's context

type ItemHandlerFn

type ItemHandlerFn func(*http.Request, storage.ReadStore) (pub.Item, error)

ItemHandlerFn is the type that we're using to represent handlers that return ActivityStreams objects. It needs to implement the http.Handler interface

func (ItemHandlerFn) ServeHTTP

func (i ItemHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for the ItemHandlerFn type

func (ItemHandlerFn) Storage

func (i ItemHandlerFn) Storage(r *http.Request) (storage.Store, error)

func (ItemHandlerFn) ValidMethod

func (i ItemHandlerFn) ValidMethod(r *http.Request) bool

ValidMethod validates if the current handler can process the current request

func (ItemHandlerFn) ValidateRequest

func (i ItemHandlerFn) ValidateRequest(r *http.Request) (int, error)

ValidateRequest validates if the current handler can process the current request

type MethodValidator

type MethodValidator interface {
	ValidMethod(r *http.Request) bool
}

MethodValidator is the interface need to be implemented to specify if an HTTP request's method is supported by the implementor object

type RequestValidator

type RequestValidator interface {
	ValidateRequest(r *http.Request) (int, error)
}

RequestValidator is the interface need to be implemented to specify if the whole HTTP request is valid in the context of the implementor object

Jump to

Keyboard shortcuts

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