shared

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package shared provides static assets shared across all unum web UIs.

Index

Constants

This section is empty.

Variables

View Source
var Assets embed.FS

Functions

func FreePort

func FreePort() (int, error)

FreePort returns a random free TCP port on localhost.

func OpenBrowser

func OpenBrowser(url string)

OpenBrowser opens url in the default browser after a short delay.

func PrintStartupBanner

func PrintStartupBanner(toolName, url string)

PrintStartupBanner writes the tool startup lines to stderr.

func RegisterMetrics added in v1.3.0

func RegisterMetrics(mux *http.ServeMux)

RegisterMetrics registers the /metrics endpoint for Prometheus scraping.

func RegisterUmamiProxy added in v1.3.0

func RegisterUmamiProxy(mux *http.ServeMux)

RegisterUmamiProxy registers /umami/* routes that reverse-proxy to the internal Umami instance. No-op if UMAMI_URL is empty.

func ServeAsset

func ServeAsset(fs embed.FS, path, contentType string) http.HandlerFunc

ServeAsset serves a file from fs at path with the given Content-Type.

func ServeSharedAsset

func ServeSharedAsset(path, contentType string) http.HandlerFunc

ServeSharedAsset serves a file from the shared Assets embed.

func ServeTemplate

func ServeTemplate(fs embed.FS, path string) func(d IndexData) http.HandlerFunc

ServeTemplate parses the named template from fs and serves it with data d.

Types

type IndexData

type IndexData struct {
	DarkTheme      string
	LightTheme     string
	Version        string
	ThemeData      template.JS // JSON: {dark:{cyber:{...},...}, light:{clean:{...},...}}
	UmamiEnabled   bool        // true if UMAMI_URL is set — enables JS tracking snippet
	UmamiWebsiteID string      // Umami website ID for the tracking snippet
}

IndexData holds the theme config injected into HTML templates.

func NewIndexData added in v1.2.0

func NewIndexData(dark, light, version string) IndexData

NewIndexData builds IndexData with all palette CSS vars pre-serialised.

Jump to

Keyboard shortcuts

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