-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (29 loc) · 913 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
34
35
36
37
package main
import (
"os"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/day-dreams/vshare.zhangnan.xyz/internal/bootstrap"
"github.com/day-dreams/vshare.zhangnan.xyz/internal/cgi"
"github.com/day-dreams/vshare.zhangnan.xyz/internal/config"
"github.com/day-dreams/vshare.zhangnan.xyz/internal/utils"
)
func main() {
bootstrap.Bootstrap()
r := gin.New()
r.Use(gin.Logger())
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
}))
r.GET("/version", func(c *gin.Context) {
utils.GinJson(c, map[string]interface{}{
"version": config.GetString("version"),
}, nil)
})
r.GET("/", cgi.Index())
r.GET("/api/video/info/demo", cgi.VideoInfoDemo())
r.GET("/api/video/hls/playlist", cgi.M3u8PlayList())
r.GET("/api/video/hls/segment", cgi.M3u8Segment())
addr := os.Getenv("addr")
r.Run(addr) // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}