ace/servers/webserver/server.go

35 lines
652 B
Go
Raw Normal View History

2022-09-26 03:04:07 +00:00
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
2022-09-27 02:21:06 +00:00
RTCConnector *webrtcconnection.Connection
2022-09-26 03:04:07 +00:00
}
2022-09-26 08:07:25 +00:00
func NewServer(o *Options) (*Server, error) {
rtc, err := webrtcconnection.New(o.WebRTC)
if err != nil {
return nil, err
}
2022-09-26 03:04:07 +00:00
s := &Server{
options: o,
webServer: gin.New(),
2022-09-27 02:21:06 +00:00
RTCConnector: rtc,
2022-09-26 03:04:07 +00:00
}
2022-09-26 08:07:25 +00:00
return s, nil
2022-09-26 03:04:07 +00:00
}
func (s *Server) Run() error {
logrus.Debug("webserver running")
defer logrus.Debug("webserver exit")
s.setupRoute()
return s.webServer.Run(s.options.Listen)
}