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 ¶
- func EnsurePushConfig(ctx context.Context, cfg pushConfigStore) error
- func ManifestHandler(w http.ResponseWriter, r *http.Request)
- func ServiceWorkerHandler(w http.ResponseWriter, r *http.Request)
- type BrowserSubscription
- type PushDevice
- type PushHandler
- type PushService
- func (s *PushService) Devices(ctx context.Context, userID string) ([]PushDevice, error)
- func (s *PushService) PublicKey() string
- func (s *PushService) SendTest(ctx context.Context, userID, endpoint string) (int, error)
- func (s *PushService) SendToUser(ctx context.Context, userID, title, body, url string) (int, error)
- func (s *PushService) Subscribe(ctx context.Context, userID, userAgent string, req BrowserSubscription) error
- func (s *PushService) Unsubscribe(ctx context.Context, userID, endpoint string) error
- func (s *PushService) UserPushID(userID string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsurePushConfig ¶ added in v0.15.0
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 PushDevice ¶ added in v0.15.0
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) SendToUser ¶ added in v0.15.0
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