mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-02 15:51:11 +08:00
fix if cfg.Pages.StaticDir is "" issue
This commit is contained in:
parent
74a22be16c
commit
44cc5d5677
1 changed files with 12 additions and 2 deletions
14
main.go
14
main.go
|
|
@ -234,8 +234,18 @@ func setupPages(cfg *config.Config, r *touka.Engine) {
|
|||
}
|
||||
|
||||
case "external":
|
||||
r.SetUnMatchFS(http.Dir(cfg.Pages.StaticDir))
|
||||
|
||||
if cfg.Pages.StaticDir == "" {
|
||||
logger.Errorf("Pages Mode is 'external' but StaticDir is empty. Using embedded pages instead.")
|
||||
err := setInternalRoute(cfg, r)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to load embedded pages: %s", err)
|
||||
fmt.Printf("Failed to load embedded pages: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
extPageFS := os.DirFS(cfg.Pages.StaticDir)
|
||||
r.SetUnMatchFS(http.FS(extPageFS))
|
||||
}
|
||||
default:
|
||||
// 处理无效的Pages Mode
|
||||
logger.Warnf("Invalid Pages Mode: %s, using default embedded theme", cfg.Pages.Mode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue