interactions yay!!
This commit is contained in:
parent
b9a05bedf9
commit
f60033a3e4
30 changed files with 716 additions and 44 deletions
46
main.go
46
main.go
|
@ -1,36 +1,15 @@
|
|||
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"
|
||||
"git.sapphic.engineer/roleypoly/v4/roleypoly"
|
||||
)
|
||||
|
||||
//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",
|
||||
// }),
|
||||
// }))
|
||||
app := roleypoly.CreateFiberApp()
|
||||
roleypoly.SetupRoutes(app)
|
||||
|
||||
listenAddr := os.Getenv("LISTEN_ADDR")
|
||||
if listenAddr == "" {
|
||||
|
@ -39,22 +18,3 @@ func main() {
|
|||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue