-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (36 loc) · 880 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
48
49
package main
import (
"github.com/gin-gonic/gin"
"vsus.app/tobycm/video-to-curl/routes"
env "github.com/Netflix/go-env"
)
type Environment struct {
TempDir string `env:"TEMP_DIR"`
ListenAddress string `env:"ADDRESS"`
}
var (
environment Environment
)
func runServer() {
router := gin.New()
root := router.Group("/")
root.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Welcome to tobycm's video to cURL service :)",
})
})
watchRoute := root.Group("/watch")
routes.AddWatchRoute(watchRoute, routes.WatchRouteOptions{
TempDir: environment.TempDir,
})
if environment.ListenAddress == "" {
environment.ListenAddress = ":3000"
}
router.Run(environment.ListenAddress)
}
func main() {
if _, err := env.UnmarshalFromEnviron(&environment); err != nil {
panic(err)
}
runServer()
}