init:first commit

This commit is contained in:
Louis Dalibard 2024-04-27 12:25:21 +02:00
parent 8c5ae7fb10
commit 8d9b91a097
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,6 @@
package config
var Host = ":3125"
var InstallDir = "./"
var ServeDirs = map[string]string{
"leech": "/home/ontake/Dev/go/leech",

13
main.go
View File

@ -1,14 +1,19 @@
package main
import (
"embed"
"leech/config"
"leech/route"
"path"
"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() {
app := fiber.New()
app.Use(logger.New(logger.Config{
@ -17,7 +22,11 @@ func main() {
app.Get("/:req", route.HandleList)
app.Get("/", route.HandleList)
app.Static("/assets", path.Join(config.InstallDir, "assets"))
app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.FS(assetsEmbed),
PathPrefix: "assets",
Browse: true,
}))
for dirName, dirToServe := range config.ServeDirs {
app.Static("/serve/"+dirName, dirToServe)