webpush

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = 4 * 7 * 24 * 60 * 60

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Subscription

type Subscription struct {
	Endpoint string           `json:"endpoint"`
	Keys     SubscriptionKeys `json:"keys"`
}

type SubscriptionKeys

type SubscriptionKeys struct {
	P256DH string `json:"p256dh"`
	Auth   string `json:"auth"`
}

type VapidDetails

type VapidDetails struct {
	Subject   string `json:"subject"`
	VapidKeys `json:",inline"`
}

type VapidKeys

type VapidKeys struct {
	PublicKey  string `json:"publicKey"`
	PrivateKey string `json:"privateKey"`
}

func GenerateVapidKeys

func GenerateVapidKeys() (*VapidKeys, error)

type WebPushClient

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

func DefaultWebPushClient

func DefaultWebPushClient() *WebPushClient

func NewWebPushClient

func NewWebPushClient(httpClient HTTPClient, jwtSigner auth.WebPushJwtSigner, encoder ece.WebPushEncoder) *WebPushClient

func (*WebPushClient) Send

func (c *WebPushClient) Send(payload []byte, info *WebPushInfo, options *WebPushOptions) (*http.Response, error)

func (*WebPushClient) SendWithContext added in v0.2.0

func (c *WebPushClient) SendWithContext(ctx context.Context, payload []byte, info *WebPushInfo, options *WebPushOptions) (*http.Response, error)

type WebPushInfo

type WebPushInfo struct {
	Subscription Subscription
	VapidDetails VapidDetails
}

type WebPushOptions

type WebPushOptions struct {
	Urgency string
	Topic   string
	TTL     int
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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