feat(loading_page): move loading page css to style.css and serve as static asset

This commit is contained in:
yusing
2025-11-06 20:32:40 +08:00
parent ef893974ea
commit d57d76dc65
4 changed files with 108 additions and 104 deletions

View File

@@ -47,6 +47,10 @@ func isFaviconPath(path string) bool {
return path == "/favicon.ico"
}
func isLoadingPageCSSPath(path string) bool {
return path == "/style.css"
}
func (w *Watcher) redirectToStartEndpoint(rw http.ResponseWriter, r *http.Request) {
uri := "/"
if w.cfg.StartEndpoint != "" {
@@ -96,6 +100,13 @@ func (w *Watcher) wakeFromHTTP(rw http.ResponseWriter, r *http.Request) (shouldN
return false
}
if isLoadingPageCSSPath(r.URL.Path) {
rw.Header().Set("Content-Type", "text/css")
rw.WriteHeader(http.StatusOK)
rw.Write(cssBytes)
return false
}
// Check if start endpoint is configured and request path matches
if w.cfg.StartEndpoint != "" && r.URL.Path != w.cfg.StartEndpoint {
http.Error(rw, "Forbidden: Container can only be started via configured start endpoint", http.StatusForbidden)