From 4ae50798ab0d59cddabfa8ff40664f45be5de41c Mon Sep 17 00:00:00 2001 From: moecinnamo Date: Thu, 27 Nov 2025 22:43:00 +0800 Subject: [PATCH] Resolve the possible panic caused by the document server --- docs/css/index.css | 0 docs/index.html | 11 +++++++++++ main.go | 8 ++------ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 docs/css/index.css diff --git a/docs/css/index.css b/docs/css/index.css new file mode 100644 index 0000000..e69de29 diff --git a/docs/index.html b/docs/index.html index 5035b6e..4c13a20 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,6 +5,17 @@ + + + + + + + + + + + diff --git a/main.go b/main.go index 1e2bc98..d25fbe6 100644 --- a/main.go +++ b/main.go @@ -68,9 +68,7 @@ func staticFileHandler(w http.ResponseWriter, r *http.Request) { // Clean path, make sure it starts with "docs/" path = strings.TrimPrefix(path, "/") if path == "" { - if err := notFoundTemplate.Execute(w, ""); err != nil { - log.Printf("[Error] Failed to render error page: %v", err) - } + notFoundHandler(w, r) return } @@ -79,9 +77,7 @@ func staticFileHandler(w http.ResponseWriter, r *http.Request) { data, err := webFiles.ReadFile(filePath) if err != nil { log.Printf("[Error] Static file not found: %s", filePath) - if err := notFoundTemplate.Execute(w, ""); err != nil { - log.Printf("[Error] Failed to render error page: %v", err) - } + notFoundHandler(w, r) return }