38 lines
812 B
Go
38 lines
812 B
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.Get("/api/health", handler.Health)
|
|
|
|
log.Fatal(app.Listen(":1947"))
|
|
}
|