Files
Adrian Zürcher 6f532ef4b0
Some checks failed
Build Quasar SPA and Go Backend for lightController / build (amd64, .exe, windows) (push) Failing after 1m30s
Build Quasar SPA and Go Backend for lightController / build (amd64, , linux) (push) Successful in 6m1s
Build Quasar SPA and Go Backend for lightController / build (arm, 6, , linux) (push) Successful in 6m9s
Build Quasar SPA and Go Backend for lightController / build (arm64, , linux) (push) Successful in 4m45s
fix repo links
2025-08-11 10:37:48 +02:00

39 lines
814 B
Go

package server
import (
"fmt"
"sync"
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
"gitea.tecamino.com/paadi/tecamino-logger/logging"
"github.com/gin-gonic/gin"
)
// server model for database manager websocket
type Server struct {
Routes *gin.Engine
sync.RWMutex
Logger *logging.Logger
}
// initalizes new dbm server
func NewServer() *Server {
return &Server{
Routes: gin.Default(),
}
}
// serve dbm as http
func (s *Server) ServeHttp(ip string, port uint) error {
return s.Routes.Run(fmt.Sprintf("%s:%d", ip, port))
}
// serve dbm as http
func (s *Server) ServeHttps(port uint, cert cert.Cert) error {
// generate self signed tls certificate
if err := cert.GenerateSelfSignedCert(); err != nil {
return err
}
return s.Routes.RunTLS(fmt.Sprintf(":%d", port), cert.CertFile, cert.KeyFile)
}