initial
This commit is contained in:
62
server/router/router.go
Normal file
62
server/router/router.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"wnzl-snow/db"
|
||||
"wnzl-snow/dist"
|
||||
"wnzl-snow/internal/settings"
|
||||
"wnzl-snow/server/handler"
|
||||
"wnzl-snow/server/middleware"
|
||||
)
|
||||
|
||||
func New(logger *slog.Logger, database db.Database, buildTime string, sha1ver string, goVersion string, settings *settings.Settings) http.Handler {
|
||||
h := &handler.Handler{
|
||||
Logger: logger,
|
||||
Database: database,
|
||||
BuildTime: buildTime,
|
||||
SHA1Ver: sha1ver,
|
||||
GoVersion: goVersion,
|
||||
//VcCreds: creds,
|
||||
//Secret: secret,
|
||||
Settings: settings,
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("/assets/", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
|
||||
mux.HandleFunc("/", h.Home)
|
||||
|
||||
mux.HandleFunc("/api/now/import/x_dusa2_itom_inc_imp", h.NewSnow)
|
||||
|
||||
// mux.HandleFunc("/api/event/vm/create", h.VmCreateEvent)
|
||||
// mux.HandleFunc("/api/event/vm/modify", h.VmModifyEvent)
|
||||
// mux.HandleFunc("/api/event/vm/move", h.VmMoveEvent)
|
||||
// mux.HandleFunc("/api/event/vm/delete", h.VmDeleteEvent)
|
||||
// mux.HandleFunc("/api/import/vm", h.VmImport)
|
||||
// // Use this when we need to manually remove a VM from the database to clean up
|
||||
// mux.HandleFunc("/api/inventory/vm/delete", h.VmCleanup)
|
||||
|
||||
// // add missing data to VMs
|
||||
// //mux.HandleFunc("/api/inventory/vm/update", h.VmUpdateDetails)
|
||||
|
||||
// // temporary endpoint
|
||||
// mux.HandleFunc("/api/cleanup/updates", h.UpdateCleanup)
|
||||
// //mux.HandleFunc("/api/cleanup/vcenter", h.VcCleanup)
|
||||
|
||||
// mux.HandleFunc("/api/report/inventory", h.InventoryReportDownload)
|
||||
// mux.HandleFunc("/api/report/updates", h.UpdateReportDownload)
|
||||
|
||||
// // endpoint for encrypting vcenter credential
|
||||
// mux.HandleFunc("/api/encrypt", h.EncryptData)
|
||||
|
||||
// Register pprof handlers
|
||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
|
||||
return middleware.NewLoggingMiddleware(logger, mux)
|
||||
}
|
Reference in New Issue
Block a user