server

package
v0.0.0-...-d2c7ade Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestLoggerMiddleware

func RequestLoggerMiddleware(r *mux.Router) mux.MiddlewareFunc

Types

type ActivityInbox

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

func (*ActivityInbox) Follow

func (ai *ActivityInbox) Follow(w http.ResponseWriter, act activity.Activity, body []byte)

func (*ActivityInbox) GetHTTP

func (ai *ActivityInbox) GetHTTP(w http.ResponseWriter, r *http.Request)

GetHTTP handles GET requests to the inbox, which we don't do

func (*ActivityInbox) PostHTTP

func (ai *ActivityInbox) PostHTTP(w http.ResponseWriter, r *http.Request)

PostHTTP handles POST requests to the inbox. This is where the bulk of handling communications from remote federated servers happens. e.g. Follow requests will come in through here.

func (*ActivityInbox) Unfollow

func (ai *ActivityInbox) Unfollow(w http.ResponseWriter, undo activity.Activity, follow activity.Activity)

type ActivityOutbox

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

func (*ActivityOutbox) GetLatestNotes

func (ao *ActivityOutbox) GetLatestNotes(n int) []storage.Note

func (*ActivityOutbox) NewItem

func (ao *ActivityOutbox) NewItem(item rss.Item)

NewItem is called when a new RSS item is detected by the watcher

func (*ActivityOutbox) SendToFollower

func (ao *ActivityOutbox) SendToFollower(obj storage.Note, follower storage.Follow)

func (*ActivityOutbox) SendToFollowers

func (ao *ActivityOutbox) SendToFollowers(obj storage.Note)

func (*ActivityOutbox) ServeHTTP

func (ao *ActivityOutbox) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ActivityOutbox) StatusCode

func (ao *ActivityOutbox) StatusCode(code int)

StatusCode is called by the RSS watcher to report the latest fetch status code

func (*ActivityOutbox) WatchRSS

func (ao *ActivityOutbox) WatchRSS(ctx context.Context)

WatchRSS watches an RSS feed for new items and saves them as ActivityPub objects

type ActivityService

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

func NewService

func NewService(cfg Config) *ActivityService

NewService creates an http service to listen for ActivityPub requests

func (*ActivityService) ActivityRequest

func (s *ActivityService) ActivityRequest(method string, url string, v any) (*http.Request, error)

ActivityRequest creates an http request for sending ActivityPub communications

func (*ActivityService) GetActor

func (s *ActivityService) GetActor(id string) (*activity.Actor, error)

GetActor finds the remote endpoint for the actor ID, which is assumed to be a URL. Blocks until we get a response or the context is cancelled or times out. TODO: Include a context param.

func (*ActivityService) GetActorPublicKey

func (s *ActivityService) GetActorPublicKey(id string) crypto.PublicKey

GetActorPublicKey fetches the public key ID associated with the given actor URL. Blocks until a result is returned. TODO: Include a context param.

func (*ActivityService) ListenAndServe

func (s *ActivityService) ListenAndServe(ctx context.Context) error

ListenAndServe; listen for http requests and serve responses

func (*ActivityService) Start

func (s *ActivityService) Start(ctx context.Context)

Start running the ActivityPub service and return immediately

func (*ActivityService) Stop

func (s *ActivityService) Stop(ctx context.Context)

Stop anything related to the service before exiting

type ActivityUser

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

type Config

type Config struct {
	URL    string       `json:"url"` // public-facing URL
	Server serverConfig `json:"server"`
	Users  []userConfig `json:"users"`
}

func ReadConfig

func ReadConfig(b []byte) (config Config, err error)

func (Config) PublicHost

func (c Config) PublicHost() string

type FollowResponse

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

func (*FollowResponse) Prepare

func (f *FollowResponse) Prepare(pipeline *OutputPipeline) (*http.Request, error)

func (*FollowResponse) Receive

func (f *FollowResponse) Receive(resp *http.Response)

func (*FollowResponse) String

func (f *FollowResponse) String() string

type NoteActivity

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

func (*NoteActivity) Prepare

func (f *NoteActivity) Prepare(pipeline *OutputPipeline) (*http.Request, error)

func (*NoteActivity) Receive

func (f *NoteActivity) Receive(resp *http.Response)

func (*NoteActivity) String

func (f *NoteActivity) String() string

type OutputPipeline

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

OutputPipeline is intended to be an asychronous rate-limited output pipeline for sending http requests. The idea is to be able to queue up a large number of requests to send staggered over time, rather than all at once. (The rate limiting is not yet implemented.)

func NewPipeline

func NewPipeline() *OutputPipeline

func (*OutputPipeline) Flush

func (p *OutputPipeline) Flush()

Flush blocks until the pipeline is empty

func (*OutputPipeline) Queue

func (p *OutputPipeline) Queue(handler QueueHandler)

func (*OutputPipeline) Run

func (p *OutputPipeline) Run(ctx context.Context) error

Run waits for channel messages and handles them. Expected to be run in a goroutine.

func (*OutputPipeline) SendAndWait

func (p *OutputPipeline) SendAndWait(r *http.Request, accept func(resp *http.Response))

func (*OutputPipeline) Stop

func (p *OutputPipeline) Stop()

type QueueHandler

type QueueHandler interface {
	fmt.Stringer
	Prepare(*OutputPipeline) (*http.Request, error)
	Receive(resp *http.Response)
}

type UnfollowResponse

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

func (*UnfollowResponse) Prepare

func (f *UnfollowResponse) Prepare(pipeline *OutputPipeline) (*http.Request, error)

func (*UnfollowResponse) Receive

func (f *UnfollowResponse) Receive(resp *http.Response)

func (*UnfollowResponse) String

func (f *UnfollowResponse) String() string

Directories

Path Synopsis
A simple telemetry package.
A simple telemetry package.

Jump to

Keyboard shortcuts

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