uni/WEB43-diary/main.go

43 lines
877 B
Go

package main
import (
"embed"
"fmt"
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"gitea.zokki.net/zokki/uni/web43-diary/internal/config"
"gitea.zokki.net/zokki/uni/web43-diary/internal/database"
"gitea.zokki.net/zokki/uni/web43-diary/internal/routes"
)
//go:embed assets
var assetFS embed.FS
func main() {
database.CreateTablesFromQueue()
router := chi.NewRouter()
router.Use(
middleware.Logger,
middleware.CleanPath,
// middleware.SupressNotFound(router),
middleware.Recoverer,
middleware.Maybe(middleware.NoCache, func(r *http.Request) bool { return config.EnvironmentDevelopment.IsDevelopment() }),
middleware.StripSlashes,
)
routes.RegisterRoutes(router, &assetFS)
server := http.Server{
Addr: fmt.Sprintf(":%d", config.Config.Port),
Handler: router,
}
log.Fatal(server.ListenAndServe())
}