35 lines
652 B
Go
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)
|
|
}
|