add favicon

This commit is contained in:
2025-10-10 09:44:25 +01:00
parent 075838150d
commit 14a94feed6

View File

@@ -179,6 +179,9 @@ func (s *Server) UserInterface() {
s.challengeMutex.Unlock()
}
// Serve favicon.ico by serving orly.png
s.mux.HandleFunc("/favicon.ico", s.handleFavicon)
// Serve the main login interface (and static assets) or proxy in dev mode
s.mux.HandleFunc("/", s.handleLoginInterface)
@@ -203,6 +206,26 @@ func (s *Server) UserInterface() {
s.mux.HandleFunc("/api/sprocket/config", s.handleSprocketConfig)
}
// handleFavicon serves orly.png as favicon.ico
func (s *Server) handleFavicon(w http.ResponseWriter, r *http.Request) {
// In dev mode with proxy configured, forward to dev server
if s.devProxy != nil {
s.devProxy.ServeHTTP(w, r)
return
}
// Serve orly.png as favicon.ico from embedded web app
w.Header().Set("Content-Type", "image/png")
w.Header().Set("Cache-Control", "public, max-age=86400") // Cache for 1 day
// Create a request for orly.png and serve it
faviconReq := &http.Request{
Method: "GET",
URL: &url.URL{Path: "/orly.png"},
}
ServeEmbeddedWeb(w, faviconReq)
}
// handleLoginInterface serves the main user interface for login
func (s *Server) handleLoginInterface(w http.ResponseWriter, r *http.Request) {
// In dev mode with proxy configured, forward to dev server