50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/compress"
|
|
"github.com/gofiber/fiber/v2/middleware/logger"
|
|
"github.com/gofiber/fiber/v2/middleware/recover"
|
|
"github.com/gofiber/template/html/v2"
|
|
|
|
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/handler"
|
|
)
|
|
|
|
func main() {
|
|
engine := html.New("./views", ".html")
|
|
engine.Reload(true)
|
|
engine.AddFunc("svg", func(name string) string {
|
|
return ""
|
|
})
|
|
|
|
app := fiber.New(fiber.Config{
|
|
Views: engine,
|
|
})
|
|
|
|
app.Use(logger.New())
|
|
app.Use(recover.New())
|
|
app.Use(compress.New())
|
|
app.Static("/static", "./static")
|
|
|
|
app.Get("/", handler.Dashboard)
|
|
app.Get("/hosts", handler.DashboardList)
|
|
app.Post("/hosts", handler.CreateHost)
|
|
app.Delete("/hosts/:id", handler.DeleteHost)
|
|
app.Get("/snippets", handler.Snippets)
|
|
app.Get("/snippets/grid", handler.SnippetGrid)
|
|
app.Post("/snippets", handler.CreateSnippet)
|
|
app.Delete("/snippets/:id", handler.DeleteSnippet)
|
|
app.Get("/keychain", handler.Keychain)
|
|
app.Get("/keys/grid", handler.KeyGrid)
|
|
app.Post("/keys", handler.CreateKey)
|
|
app.Delete("/keys/:id", handler.DeleteKey)
|
|
app.Get("/settings", handler.Settings)
|
|
app.Post("/settings", handler.UpdateConfig)
|
|
app.Get("/brief", handler.Brief)
|
|
app.Get("/api/health", handler.Health)
|
|
|
|
log.Fatal(app.Listen(":1947"))
|
|
}
|