web

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Browsers = [...]Browser{
	{"Chrome", *regexp.MustCompile("https://(android|fcm).googleapis.com/(gcm|fcm)/send/"), *regexp.MustCompile("<TITLE>(.*)</TITLE>")},
	{"Firefox", *regexp.MustCompile("https://updates.push.services.mozilla.com/wpush"), *regexp.MustCompile("\\\"errno\\\":\\s(\\d+)")},
}

Browsers available

Functions

This section is empty.

Types

type Browser

type Browser struct {
	Name     string
	ReDetect regexp.Regexp
	ReError  regexp.Regexp
}

Browser type

type Client

type Client struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client type

func NewClient

func NewClient(vapidPrivateKey string, vapidPublicKey string) *Client

NewClient returns a new web.Client

func (*Client) Push

func (c *Client) Push(n *Notification) (*Response, error)

Push sends a notification using Webpush

type Notification

type Notification struct {
	Subscription *Subscription           `json:"subscription,omitempty"`
	Payload      *map[string]interface{} `json:"payload,omitempty"`
	TimeToLive   *uint                   `json:"time_to_live,omitempty"`
}

Notification type

type Response

type Response struct {
	StatusCode int
	Body       string
}

Response type

type Subscription

type Subscription struct {
	Endpoint string `json:"endpoint,omitempty"`
	Key      string `json:"key,omitempty"`
	Auth     string `json:"auth,omitempty"`
}

Subscription type

Jump to

Keyboard shortcuts

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