Files
Laterna/cmd/internal/http/server.go
T
Siesta 57592b4987 feat: a lot
i did a lot of work, and i also forgot to add commits regularly. I added the controller routes to create and delete controllers, improved error handling und improved the authentification process. I'm gonna add an websocket next and then I should be hopefully done with the foundations of this project. I may also add anviewControllers route which respons with every available controller
2025-07-20 18:31:38 +02:00

32 lines
894 B
Go

package http
import (
"fmt"
"net/http"
"github.com/siestaw/laterna/server/cmd/internal/config"
"github.com/siestaw/laterna/server/cmd/internal/db"
"github.com/siestaw/laterna/server/cmd/internal/logger"
"github.com/siestaw/laterna/server/cmd/internal/routes"
)
func StartHTTPServer() {
router := http.NewServeMux()
routes.RegisterColorRoutes(router)
routes.RegisterControllerRoutes(router)
if !db.ControllerExists(0) {
adminToken := db.CreateAdmin()
fmt.Println("IMPORTANT")
fmt.Println("- - - - - - - - - - - - - - - - - - ")
fmt.Println("ADMIN TOKEN:")
fmt.Printf("%s\n", adminToken)
fmt.Println("REGENERATE THE TOKEN BY RUNNING WITH -resetAdminToken")
fmt.Println("- - - - - - - - - - - - - - - - - - ")
}
port := config.AppConfig.HTTP.Port
logger.HTTPLogger.Printf("HTTP Server running on :%v", port)
http.ListenAndServe(fmt.Sprintf(":%d", port), router)
}