package main // import "git.sapphic.engineer/roleypoly/v4" import ( "embed" "log" "net/http" "os" "github.com/goccy/go-json" "github.com/gofiber/fiber/v3" "github.com/gofiber/template/html/v2" ) //go:embed templates/* var templatesfs embed.FS func main() { // storageDir := getStorageDirectory() viewEngine := html.NewFileSystem(http.FS(templatesfs), ".html") app := fiber.New(fiber.Config{ JSONEncoder: json.Marshal, JSONDecoder: json.Unmarshal, Views: viewEngine, ViewsLayout: "main", }) // app.Use(session.New(session.Config{ // Storage: pebble.New(pebble.Config{ // Path: storageDir + "/sessions", // }), // })) listenAddr := os.Getenv("LISTEN_ADDR") if listenAddr == "" { listenAddr = ":8169" } log.Fatal(app.Listen(listenAddr)) } func getStorageDirectory() string { path := os.Getenv("STORAGE_DIR") if path == "" { path = "./.storage" } _, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { err := os.MkdirAll(path, 0744) if err != nil { log.Fatalln("failed to create storage directory: ", err) } } } return path }