Files
vctp2/server/router/router.go
Nathan Coad 18a2b7227e
Some checks failed
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 Build is failing
structure appears to work
2024-09-12 11:59:41 +10:00

27 lines
573 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) http.Handler {
h := &handler.Handler{
Logger: logger,
Database: database,
}
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/update", h.VmUpdate)
return middleware.NewLoggingMiddleware(logger, mux)
}