Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ReceiveConfig ¶
type ReceiveConfig struct {
Validators []Validator
}
ReceiveConfig is a configuration object for the `ReceiveRequest` function.
func NewReceiveConfig ¶
func NewReceiveConfig(options ...Option) ReceiveConfig
NewReceiveConfig creates a new ReceiveConfig object with default settings, and applies any provided options to override the defaults.
type RouteHandler ¶
RouteHandler is a function that handles a specific type of ActivityPub activity. RouteHandlers are registered with the Router object along with the names of the activity types that they correspond to.
type Router ¶
type Router[T any] struct { // contains filtered or unexported fields }
Router is a simple object that routes incoming ActivityPub activities to the appropriate handler
func (*Router[T]) Add ¶
func (router *Router[T]) Add(activityType string, objectType string, routeHandler RouteHandler[T])
Add puts a new route to the router. You can use "*" as a wildcard for either the activityType or objectType. The Handler method tries to match handlers from most specific to least specific. activity/object activity/* */object */*
For performance reasons, this function is not thread-safe. So, you should add all routes before starting the server, for instance, in your app's `init` functions.
type Validator ¶
type Validator interface { // Validate checks incoming HTTP requests for validity. If a document is // valid, it returns `ResultValid`. If the Validator cannot validate this // document, it returns `ResultUnknown`. If the Validator can say with // certainty that the document is invalid, it returns `ResultInvalid`. Validate(*http.Request, *streams.Document) validator.Result }
Validator interface wraps the Validate method, which identifies whether a document received in an actor's inbox is valid or not. Multiple validators can be stacked to validate a document, so if one validator returns `false`, the document is not necessary invalid. It just can't be validated by this one validator.