diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/nebbet/main.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/cmd/nebbet/main.go b/cmd/nebbet/main.go index e7029c6..8efd504 100644 --- a/cmd/nebbet/main.go +++ b/cmd/nebbet/main.go @@ -14,7 +14,6 @@ package main import ( "flag" "fmt" - "net/http" "os" "nebbet.no/internal/admin" @@ -111,21 +110,21 @@ func cmdServe(args []string) { } }() + // Create admin server with Gin adminSrv := admin.NewServer(postsDir, passwordFile, b) + engine := adminSrv.Engine() - mux := http.NewServeMux() - // Admin routes — handled dynamically, never from the static output dir. - mux.Handle("/admin/", http.StripPrefix("/admin", adminSrv.Engine())) - // Serve dependencies (Crepe, etc.) - mux.Handle("/lib/", http.StripPrefix("/lib/", http.FileServer(http.Dir("lib")))) - // Everything else — serve the pre-built static files. - mux.Handle("/", http.FileServer(http.Dir(outputDir))) + // Serve dependencies (lib/) + engine.Static("/lib", "lib") + + // Serve static site from public/ + engine.Static("/", outputDir) addr := ":" + *port fmt.Printf("listening on http://localhost%s\n", addr) fmt.Printf(" public site: http://localhost%s/\n", addr) fmt.Printf(" admin UI: http://localhost%s/admin/\n", addr) - if err := http.ListenAndServe(addr, mux); err != nil { + if err := engine.Run(addr); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } |
