leech/main.go
2024-06-10 21:36:26 +02:00

40 lines
764 B
Go

package main
import (
"embed"
"leech/config"
"leech/route"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/logger"
)
//go:embed assets/**
var assetsEmbed embed.FS
func main() {
config.Init()
app := fiber.New()
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.FS(assetsEmbed),
PathPrefix: "assets",
Browse: true,
}))
for dirName, dirToServe := range config.Config.ServeDirs {
app.Static("/serve/"+dirName, dirToServe)
}
app.Use("/thumb", route.HandleThumb)
app.Use("/", route.HandleList)
app.Listen(config.Config.Host)
}