cmd/pkgserver: move ui internal
This avoids inadvertently exporting a go package. This change also cleans up generate layout. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
21
cmd/pkgserver/internal/ui/ui.go
Normal file
21
cmd/pkgserver/internal/ui/ui.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Package ui holds the static web UI.
|
||||
package ui
|
||||
|
||||
import "net/http"
|
||||
|
||||
func serveWebUI(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
w.Header().Set("Pragma", "no-cache")
|
||||
w.Header().Set("Expires", "0")
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
w.Header().Set("X-XSS-Protection", "1")
|
||||
w.Header().Set("X-Frame-Options", "DENY")
|
||||
|
||||
http.ServeFileFS(w, r, content, "static/index.html")
|
||||
}
|
||||
|
||||
// Register arranges for mux to serve the embedded frontend.
|
||||
func Register(mux *http.ServeMux) {
|
||||
mux.Handle("GET /", http.FileServer(http.FS(content)))
|
||||
mux.HandleFunc("GET /{$}", serveWebUI)
|
||||
}
|
||||
Reference in New Issue
Block a user