Documentation
¶
Overview ¶
Package adminui serves the self-hosted admin console: one page with its script, stylesheet and icon, embedded in the binary. The page talks to the admin API under /api/admin on the same origin; the admin token is kept in the browser's session storage and sent only as a bearer header.
Mount the handler under a prefix and strip the prefix, since the page references its assets relative to itself:
mux.Handle("/admin/", http.StripPrefix("/admin", adminui.Handler()))
"/" then answers index.html and "/static/<file>" an asset.
Index ¶
Constants ¶
const CSP = "default-src 'self'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; frame-ancestors 'none'"
CSP is the Content-Security-Policy of every response: only same-origin scripts, styles and requests. The page therefore carries no inline script and no inline style; everything lives under static/.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler returns the console. The server mounts it under a prefix it strips: "/" answers index.html, "/static/<file>" an asset, anything else 404. Only GET and HEAD are served. index.html is revalidated on every load; the assets, which never change content under the same name, cache for an hour.
Types ¶
This section is empty.