indieweb

package
v0.0.0-...-7fd3dae Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	URL    *url.URL
	Params map[string][]string
}
func GetHeaderLinks(headers []string) []*Link

type Subscriber

type Subscriber struct {
	Topic     string    `json:"topic"`
	Callback  string    `json:"callback"`
	Verified  bool      `json:"verified"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

func NewSubscriber

func NewSubscriber(topic, callback string) *Subscriber

func (*Subscriber) Expired

func (s *Subscriber) Expired() bool

type Subscribers

type Subscribers []*Subscriber

func (Subscribers) Len

func (s Subscribers) Len() int

func (Subscribers) Less

func (s Subscribers) Less(i, j int) bool

func (Subscribers) Swap

func (s Subscribers) Swap(i, j int)

type Subscription

type Subscription struct {
	sync.RWMutex

	Topic string
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription(topic string) *Subscription

func (*Subscription) Confirm

func (s *Subscription) Confirm(leaseSeconds int)

func (*Subscription) Confirmed

func (s *Subscription) Confirmed() bool

func (*Subscription) Expired

func (s *Subscription) Expired() bool

func (*Subscription) MarshalJSON

func (s *Subscription) MarshalJSON() ([]byte, error)

func (*Subscription) Timedout

func (s *Subscription) Timedout(timeout time.Duration) bool

func (*Subscription) UnmarshalJSON

func (s *Subscription) UnmarshalJSON(data []byte) error

type WebSub

type WebSub struct {
	sync.RWMutex

	// Notify is the callback called when processing inbound notifications requests
	// from a hub we're subscribed to as a client for a given topic
	Notify func(topic string) error

	// ValidateTopic is a function that takes a `topic` string as input and returns `true` if it is
	// a valid topic or `false` otherwise. Consumers should override this field with a custom
	// topic validation function that suits the application.
	ValidateTopic func(topic string) bool
	// contains filtered or unexported fields
}

func NewWebSub

func NewWebSub(fn, endpoint string) *WebSub

func (*WebSub) AddSubscriber

func (ws *WebSub) AddSubscriber(subscriber *Subscriber)

func (*WebSub) DebugEndpoint

func (ws *WebSub) DebugEndpoint(w http.ResponseWriter, r *http.Request)

func (*WebSub) DelSubscriber

func (ws *WebSub) DelSubscriber(topic string, idx int)

func (*WebSub) GetHubEndpoint

func (ws *WebSub) GetHubEndpoint(target *url.URL) (hubEndpoint *url.URL, selfURL *url.URL, err error)

func (*WebSub) GetSubscriberFor

func (ws *WebSub) GetSubscriberFor(topic, callback string) (*Subscriber, int)

func (*WebSub) GetSubscription

func (ws *WebSub) GetSubscription(topic string) *Subscription

func (*WebSub) HasSubscriberFor

func (ws *WebSub) HasSubscriberFor(topic, callback string) bool

func (*WebSub) IsSubscribed

func (ws *WebSub) IsSubscribed(topic string) bool

func (*WebSub) Load

func (ws *WebSub) Load() error

func (*WebSub) NotifyEndpoint

func (ws *WebSub) NotifyEndpoint(w http.ResponseWriter, r *http.Request)

func (*WebSub) Save

func (ws *WebSub) Save() error

func (*WebSub) SendNotification

func (ws *WebSub) SendNotification(topic string)

func (*WebSub) Stats

func (ws *WebSub) Stats() (stats WebSubStats)

func (*WebSub) Subscribe

func (ws *WebSub) Subscribe(uri, callback string) error

func (*WebSub) WebSubEndpoint

func (ws *WebSub) WebSubEndpoint(w http.ResponseWriter, r *http.Request)

type WebSubStats

type WebSubStats struct {
	Topics int

	Subscribers int
	Verified    int

	Subscriptions int
	Confirmed     int
}

Jump to

Keyboard shortcuts

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