initial commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Package webui embeds the HTML templates and static assets.
|
||||
//
|
||||
// It lives at the repository root next to the files it embeds, because Go's
|
||||
// embed directive cannot reach outside its own directory. The HTTP handlers
|
||||
// that consume these assets live in internal/web.
|
||||
//
|
||||
// Everything the browser needs — Bootstrap, Bootstrap Icons and their web
|
||||
// font, and Chart.js — is vendored here rather than loaded from a CDN, so the
|
||||
// management interface works on a network with no Internet access. That is not
|
||||
// a hypothetical: a DNS server whose own UI needs working DNS to render is
|
||||
// unusable in exactly the situation an administrator most needs it.
|
||||
package webui
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed templates
|
||||
var templatesFS embed.FS
|
||||
|
||||
//go:embed static
|
||||
var staticFS embed.FS
|
||||
|
||||
// Templates returns the template tree rooted at the templates directory.
|
||||
func Templates() fs.FS {
|
||||
sub, err := fs.Sub(templatesFS, "templates")
|
||||
if err != nil {
|
||||
// Unreachable: the directory is embedded at build time.
|
||||
panic("webui: templates directory is missing from the binary: " + err.Error())
|
||||
}
|
||||
return sub
|
||||
}
|
||||
|
||||
// Static returns the static asset tree rooted at the static directory.
|
||||
func Static() fs.FS {
|
||||
sub, err := fs.Sub(staticFS, "static")
|
||||
if err != nil {
|
||||
panic("webui: static directory is missing from the binary: " + err.Error())
|
||||
}
|
||||
return sub
|
||||
}
|
||||
Reference in New Issue
Block a user