hscontrol: consolidate assets into single package

Move favicon.png, style.css, and headscale.svg to hscontrol/assets/
and create a single assets.go file with all embed directives.

Update hscontrol/handlers.go and hscontrol/templates/general.go to
use the centralized assets package.
This commit is contained in:
Kristoffer Dalby
2025-11-12 14:23:15 +01:00
committed by Kristoffer Dalby
parent 09c9762fe0
commit e3ced80278
5 changed files with 38 additions and 22 deletions

View File

@@ -2,7 +2,6 @@ package hscontrol
import (
"bytes"
_ "embed"
"encoding/json"
"errors"
"fmt"
@@ -14,6 +13,7 @@ import (
"github.com/chasefleming/elem-go/styles"
"github.com/gorilla/mux"
"github.com/juanfont/headscale/hscontrol/assets"
"github.com/juanfont/headscale/hscontrol/templates"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/rs/zerolog/log"
@@ -278,12 +278,9 @@ func (a *AuthProviderWeb) RegisterHandler(
writer.Write([]byte(templates.RegisterWeb(registrationId).Render()))
}
//go:embed assets/favicon.png
var favicon []byte
func FaviconHandler(writer http.ResponseWriter, req *http.Request) {
writer.Header().Set("Content-Type", "image/png")
http.ServeContent(writer, req, "favicon.ico", time.Unix(0, 0), bytes.NewReader(favicon))
http.ServeContent(writer, req, "favicon.ico", time.Unix(0, 0), bytes.NewReader(assets.Favicon))
}
// BlankHandler returns a blank page with favicon linked.