forked from Roverr/rtsp-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
33 lines (29 loc) · 758 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/rs/cors"
"github.com/Roverr/rtsp-stream/core"
"github.com/Roverr/rtsp-stream/core/config"
"github.com/sirupsen/logrus"
)
func main() {
config := config.InitConfig()
core.SetupLogger(config)
router, ctrls := core.GetRouter(config)
done := ctrls.ExitHandler()
handler := cors.AllowAll().Handler(router)
if config.CORS.Enabled {
handler = cors.New(cors.Options{
AllowCredentials: config.CORS.AllowCredentials,
AllowedOrigins: config.CORS.AllowedOrigins,
MaxAge: config.CORS.MaxAge,
}).Handler(router)
}
logrus.Infof("RTSP-STREAM started on %d", config.Port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), handler))
<-done
os.Exit(0)
}