push

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package push is the web-push (VAPID) notification sink. It degrades to a no-op until keys are configured, so a fresh install never fails on it.

The payload is encrypted with RFC 8291 aes128gcm and authorised with an RFC 8292 VAPID JWT. Implemented directly on crypto/* rather than pulling a dependency: it is ~120 lines and the alternative is another module to audit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sender

type Sender struct {
	PrivateKey string // base64url raw P-256 scalar
	PublicKey  string // base64url uncompressed P-256 point
	Email      string
	Client     *http.Client
	Log        *slog.Logger
}

Sender holds the VAPID identity.

func (*Sender) Enabled

func (s *Sender) Enabled() bool

Enabled reports whether VAPID keys are configured.

func (*Sender) Send

func (s *Sender) Send(sub Subscription, payload []byte) (gone bool, err error)

Send delivers one notification. It returns whether the subscription is gone (404/410), so the caller can prune it.

type Subscription

type Subscription struct {
	Endpoint string            `json:"endpoint"`
	Keys     map[string]string `json:"keys"`
}

Subscription is a browser's push endpoint plus its encryption keys.

Jump to

Keyboard shortcuts

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