-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
47 lines (38 loc) · 883 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
38
39
40
41
42
43
44
45
46
47
package main
import (
"log"
"media-server/handlers"
"media-server/utils"
"github.com/gin-gonic/gin"
)
func main() {
// Set ENVs
err := utils.SetEnv(true)
if err != nil {
log.Fatal("Error loading envs: " + err.Error())
return
}
// Initialize Server
api := gin.Default()
var port = "8080"
api.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
api.Use(nocache())
api.POST("rid", handlers.GetResourceID)
api.POST("rtc", handlers.GetRTCToken)
api.POST("start", handlers.StartRecording)
api.POST("stop", handlers.StopRecording)
api.Run(":" + port)
}
func nocache() gin.HandlerFunc {
return func(c *gin.Context) {
// set headers
c.Header("Cache-Control", "private, no-cache, no-store, must-revalidate")
c.Header("Expires", "-1")
c.Header("Pragma", "no-cache")
c.Header("Access-Control-Allow-Origin", "*")
}
}