init:first commit
This commit is contained in:
parent
8c5ae7fb10
commit
8d9b91a097
@ -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
13
main.go
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user