ace/servers/webserver/server.go
2022-09-27 10:21:06 +08:00

35 lines
652 B
Go

package webserver
import (
"git.sense-t.eu.org/ACE/ace/lib/webrtcconnection"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
type Server struct {
options *Options
webServer *gin.Engine
RTCConnector *webrtcconnection.Connection
}
func NewServer(o *Options) (*Server, error) {
rtc, err := webrtcconnection.New(o.WebRTC)
if err != nil {
return nil, err
}
s := &Server{
options: o,
webServer: gin.New(),
RTCConnector: rtc,
}
return s, nil
}
func (s *Server) Run() error {
logrus.Debug("webserver running")
defer logrus.Debug("webserver exit")
s.setupRoute()
return s.webServer.Run(s.options.Listen)
}