-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (41 loc) · 1.15 KB
/
main.go
File metadata and controls
48 lines (41 loc) · 1.15 KB
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
package main
import (
"net/http"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"gitlab.com/kayslay/vid_trimmer/config"
"gitlab.com/kayslay/vid_trimmer/pkg/video"
)
func main() {
godotenv.Load()
//set default
viper.SetDefault(config.EnvFileSize, 100)
viper.AutomaticEnv()
log.Println(viper.GetInt64(config.EnvFileSize))
port := "8080"
if viper.GetString(config.EnvPort) != "" {
port = ":" + viper.GetString(config.EnvPort)
}
svr := http.Server{
Addr: port,
Handler: http.TimeoutHandler(initRoute(), time.Minute, " server timeout"),
ReadTimeout: time.Minute,
WriteTimeout: time.Minute,
}
log.Info("serving http at " + port)
log.Fatal(svr.ListenAndServe())
}
func initRoute() http.Handler {
r := chi.NewRouter()
r.Use(middleware.Recoverer)
r.Use(middleware.Logger)
r.Mount("/download", video.Router())
r.Mount("/", http.FileServer(http.Dir("./public")))
return r
}
//"https://media.w3.org/2010/05/sintel/trailer.mp4"
//https://video.twimg.com/ext_tw_video/1261596073178652674/pu/vid/320x568/9H1vwy9y9u9xRXiK.mp4?tag=10