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 } var DefaultServer *Server func NewServer(o *Options) *Server { s := &Server{ options: o, webServer: gin.New(), rtcConnector: webrtcconnection.New(o.WebRTC), } return s } func (s *Server) Run() error { logrus.Debug("webserver running") defer logrus.Debug("webserver exit") s.setupRoute() return s.webServer.Run(s.options.Listen) } func Setup(o *Options) { DefaultServer = NewServer(o) go func() { if err := DefaultServer.Run(); err != nil { logrus.Fatal("cannot run webserver with error: ", err) } }() }