feat: add website

This commit is contained in:
tux
2025-03-03 19:44:08 +05:30
parent eb4f430ad7
commit 17fcdc73f7
21 changed files with 790 additions and 2 deletions

41
internal/server/web.go Normal file
View File

@ -0,0 +1,41 @@
package server
import (
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/tuxdotrs/trok/internal/web"
)
type TrokWeb struct {
app *fiber.App
addr string
}
func NewTrokWeb(addr string) *TrokWeb {
return &TrokWeb{
app: fiber.New(),
addr: addr,
}
}
func (t *TrokWeb) Start() {
t.app.Use("/", filesystem.New(filesystem.Config{
Root: http.FS(web.EmbedDirStatic),
PathPrefix: "dist",
Browse: true,
}))
t.app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.FS(web.EmbedDirStatic),
PathPrefix: "dist/assets",
Browse: true,
}))
t.app.Listen(t.addr)
}
func (t *TrokWeb) Stop() {
t.app.Shutdown()
}