Files
Adrian Zürcher 83cbcdaa42 updated
2025-04-29 09:16:27 +02:00

39 lines
677 B
Go

package server
import (
"artNet/cert"
"fmt"
"github.com/gin-gonic/gin"
)
type Server struct {
Routes *gin.Engine
}
type Send struct {
Set []Set `json:"subscribe"`
}
type Set struct {
Path string `json:"path"`
OnChange bool `json:"onChange"`
Depth int `json:"depth"`
Driver string `json:"driver"`
}
// Initialize new websocket server
func NewServer() *Server {
return &Server{
Routes: gin.Default(),
}
}
func (s *Server) ServeHttp(port uint) error {
return s.Routes.Run(fmt.Sprintf(":%d", port))
}
func (s *Server) ServeHttps(port uint, cert cert.Cert) error {
return s.Routes.RunTLS(fmt.Sprintf(":%d", port), cert.CertFile, cert.KeyFile)
}