Files
vctp2/server/router/router.go
Nathan Coad dd13fd6759
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing
add temp endpoint for db cleanup
2024-09-26 12:15:39 +10:00

34 lines
875 B
Go

package router
import (
"log/slog"
"net/http"
"vctp/db"
"vctp/dist"
"vctp/server/handler"
"vctp/server/middleware"
)
func New(logger *slog.Logger, database db.Database, buildTime string, sha1ver string, goVersion string) http.Handler {
h := &handler.Handler{
Logger: logger,
Database: database,
BuildTime: buildTime,
SHA1Ver: sha1ver,
GoVersion: goVersion,
}
mux := http.NewServeMux()
mux.Handle("/assets/", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
mux.HandleFunc("/", h.Home)
mux.HandleFunc("/api/event/vm/create", h.VmCreate)
mux.HandleFunc("/api/event/vm/modify", h.VmModify)
mux.HandleFunc("/api/event/vm/delete", h.VmDelete)
mux.HandleFunc("/api/import/vm", h.VmImport)
// temporary endpoint
mux.HandleFunc("/api/cleanup/updates", h.UpdateCleanup)
return middleware.NewLoggingMiddleware(logger, mux)
}