pwa

package
v0.16.13 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pwa hosts Progressive Web App glue — the dynamic web app manifest plus future hooks (service worker registration, push subscription endpoints). Kept separate from internal/pkg/api so server.go stays a wiring file and doesn't accumulate PWA logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsurePushConfig added in v0.15.0

func EnsurePushConfig(ctx context.Context, cfg pushConfigStore) error

EnsurePushConfig seeds PWA Web Push config rows and creates one VAPID keypair on first boot. Public/private keys must be generated together, so this lives outside the generic per-key config generator.

func ManifestHandler

func ManifestHandler(w http.ResponseWriter, r *http.Request)

ManifestHandler serves /public/manifest.json with the configured app name + description baked in, so downstream wick deployments install as their own brand instead of "wick". The agents shortcut name follows suit — "MyApp Agent" rather than a static fallback. Icons and theme colour stay shared from the embedded SVGs under /public/img.

Reads everything from the request context. The caller is expected to chain the existing appNameHandler middleware before this handler so ui.AppNameFromContext / ui.AppDescFromContext are populated.

func ServiceWorkerHandler added in v0.14.19

func ServiceWorkerHandler(w http.ResponseWriter, r *http.Request)

ServiceWorkerHandler serves /sw.js. It must be registered at the root path (not under /public/) so the default scope is "/". no-cache lets the browser pick up a new worker on each deploy.

Types

type BrowserSubscription added in v0.15.0

type BrowserSubscription struct {
	Endpoint       string  `json:"endpoint"`
	ExpirationTime float64 `json:"expirationTime,omitempty"`
	Keys           struct {
		P256dh string `json:"p256dh"`
		Auth   string `json:"auth"`
	} `json:"keys"`
	DeviceLabel string `json:"deviceLabel,omitempty"`
}

type PushDevice added in v0.15.0

type PushDevice struct {
	ID          string     `json:"id"`
	Endpoint    string     `json:"endpoint"`
	DeviceLabel string     `json:"deviceLabel,omitempty"`
	UserAgent   string     `json:"userAgent,omitempty"`
	LastSeenAt  *time.Time `json:"lastSeenAt,omitempty"`
	CreatedAt   time.Time  `json:"createdAt"`
}

type PushHandler added in v0.15.0

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

func NewPushHandler added in v0.15.0

func NewPushHandler(svc *PushService, auth *login.Service) *PushHandler

func (*PushHandler) Register added in v0.15.0

func (h *PushHandler) Register(mux *http.ServeMux, midd *login.Middleware)

type PushService added in v0.15.0

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

func NewPushService added in v0.15.0

func NewPushService(db *gorm.DB, cfg pushConfigStore) *PushService

func (*PushService) Devices added in v0.15.0

func (s *PushService) Devices(ctx context.Context, userID string) ([]PushDevice, error)

func (*PushService) PublicKey added in v0.15.0

func (s *PushService) PublicKey() string

func (*PushService) SendTest added in v0.15.0

func (s *PushService) SendTest(ctx context.Context, userID, endpoint string) (int, error)

func (*PushService) SendToUser added in v0.15.0

func (s *PushService) SendToUser(ctx context.Context, userID, title, body, url string) (int, error)

func (*PushService) Subscribe added in v0.15.0

func (s *PushService) Subscribe(ctx context.Context, userID, userAgent string, req BrowserSubscription) error

func (*PushService) Unsubscribe added in v0.15.0

func (s *PushService) Unsubscribe(ctx context.Context, userID, endpoint string) error

func (*PushService) UserPushID added in v0.15.0

func (s *PushService) UserPushID(userID string) string

Jump to

Keyboard shortcuts

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