diff --git a/main.go b/main.go index e3baed7..130d539 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "encoding/json" "fmt" "io" @@ -11,6 +12,9 @@ import ( "net/http" ) +//go:embed nullboard.html +var nullboard string + type server struct { db storage.DBStream crud bool @@ -21,10 +25,14 @@ func main() { as.Append(args.INT, "p", "port", 8121) as.Append(args.STRING, "db", "db type", "mapstream") as.Append(args.STRING, "dbaddr", "db addr", "/tmp/db") + as.Append(args.STRING, "level", "debug level", "info") as.Append(args.BOOL, "nocrud", "no support CRUD api", false) if err := as.Parse(); err != nil { panic(err) } + logb.Set(logb.LevelFromString(as.GetString("level"))) + + logb.Debugf("nullboard=%v", len(nullboard)) db, err := storage.New(storage.TypeFromString(as.GetString("db")), as.GetString("dbaddr")) if err != nil { @@ -50,7 +58,6 @@ func (server server) ServeHTTP(w http.ResponseWriter, r *http.Request) { defer w2.Close() w = w2 } - fileServer := http.FileServer(http.Dir("./")) switch r.URL.Path { case "/api": if server.crud { @@ -61,8 +68,8 @@ func (server server) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } default: - logb.Debug("serving dir", r.URL.Path) - fileServer.ServeHTTP(w, r) + logb.Debug("serving nullboard.html", r.URL.Path) + fmt.Fprintln(w, nullboard) return } logb.Debug("404", r.URL.Path)