summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivar <i@oiee.no>2026-04-03 14:26:21 +0200
committerivar <i@oiee.no>2026-04-03 14:26:21 +0200
commitdfa5b9d69308af36a53c66d6c5a3e9b735f0c6a9 (patch)
treec3ee597732f0bfed6031822aa64603e723e35b60
parent33310be68544d3381ac6e9899790f4a106e17e8f (diff)
downloadnebbet.no-dfa5b9d69308af36a53c66d6c5a3e9b735f0c6a9.tar.xz
nebbet.no-dfa5b9d69308af36a53c66d6c5a3e9b735f0c6a9.zip
refactor: update cmdServe to use Gin engine directly
-rw-r--r--cmd/nebbet/main.go17
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)
}