swconfig

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StrategyNetworkFirst         = "network-first"
	StrategyCacheFirst           = "cache-first"
	StrategyStaleWhileRevalidate = "stale-while-revalidate"
	StrategyNetworkOnly          = "network-only"
	DefaultOfflineURL            = "/static/offline.html"
)

Variables

View Source
var DefaultPrecacheURLs = []string{
	DefaultOfflineURL,
	"/static/css/output.css",
	"/static/css/fonts.css",
	"/static/js/alpine.min.js",
	"/static/js/htmx.min.js",
	"/static/js/common.js",
	"/static/images/goatflow-logo.svg",
	"/static/images/icon-192.png",
}

Functions

func ValidStrategy

func ValidStrategy(s string) bool

ValidStrategy reports whether s is one of the v1 fixed strategy values.

Types

type Config

type Config struct {
	Enabled                   bool        `json:"enabled"`
	Version                   string      `json:"version"`
	CacheName                 string      `json:"cache_name"`
	OfflineURL                string      `json:"offline_url"`
	PrecacheURLs              []string    `json:"precache_urls"`
	DefaultNavigationStrategy string      `json:"default_navigation_strategy"`
	Routes                    []RouteRule `json:"routes"`
}

Config is the JSON document consumed by /sw.js.

func Build

func Build(db *sql.DB, uis []pluginui.PluginUI) Config

Build creates a complete service-worker config from sysconfig and plugin UI state.

type RouteRule

type RouteRule struct {
	Path     string `json:"path"`
	Strategy string `json:"strategy"`
	Source   string `json:"source,omitempty"`
}

RouteRule describes one same-origin GET path handled by the service worker.

func PluginUIRules

func PluginUIRules(uis []pluginui.PluginUI) []RouteRule

PluginUIRules converts enabled plugin UI PWA cache routes into absolute rules.

Jump to

Keyboard shortcuts

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