goshorly/main.go

47 lines
833 B
Go
Raw Normal View History

2021-12-07 14:49:58 +00:00
package main
import (
2021-12-07 18:10:53 +00:00
"embed"
2021-12-07 14:49:58 +00:00
"log"
"net/http"
"git.ucode.space/Phil/goshorly/db"
"git.ucode.space/Phil/goshorly/routes"
2021-12-07 19:23:27 +00:00
"git.ucode.space/Phil/goshorly/utils"
2021-12-07 14:49:58 +00:00
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/gofiber/template/html"
)
2021-12-07 18:13:06 +00:00
//go:embed views/*
var viewsfs embed.FS
2021-12-07 18:10:53 +00:00
2021-12-07 18:13:06 +00:00
func main() {
2022-01-25 16:25:23 +00:00
utils.Print_Starting_Screen()
2021-12-08 10:04:28 +00:00
utils.Init_env_vars()
utils.Init_build_vars()
db.Init_redis()
2021-12-07 18:10:53 +00:00
engine := html.NewFileSystem(http.FS(viewsfs), ".html")
2021-12-07 14:49:58 +00:00
app := fiber.New(fiber.Config{
2021-12-07 18:10:53 +00:00
CaseSensitive: true,
Views: engine,
2021-12-07 14:49:58 +00:00
})
app.Get("/", routes.Gethome)
2021-12-07 14:49:58 +00:00
if utils.ESTATS == "true" {
app.Get("/stats", routes.GetStats)
}
app.Get("/:id", routes.ID)
2021-12-07 14:49:58 +00:00
app.Use(limiter.New(utils.ConfigLimiter))
2021-12-07 14:49:58 +00:00
app.Post("/", routes.Posthome)
2021-12-07 14:49:58 +00:00
2021-12-07 19:23:27 +00:00
log.Fatal(app.Listen(":" + utils.PORT))
2021-12-07 14:49:58 +00:00
}