forked from poixeai/proxify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (34 loc) · 824 Bytes
/
Copy pathmain.go
File metadata and controls
43 lines (34 loc) · 824 Bytes
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
package main
import (
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/poixeai/proxify/infra/logger"
"github.com/poixeai/proxify/infra/watcher"
"github.com/poixeai/proxify/router"
"github.com/poixeai/proxify/util"
)
func main() {
// load .env
_ = godotenv.Load()
// init logger
logger.InitLogger()
// init routes watcher
if err := watcher.InitRoutesWatcher(); err != nil {
logger.Errorf("Failed to load routes config: %v", err)
return
}
// init gin
r := gin.New()
r.SetTrustedProxies(nil)
// setup routes
router.SetRoutes(r)
// setup frontend static files
MountFrontend(r)
// start server
port := util.GetEnvPort()
if err := r.Run(":" + port); err != nil {
logger.Errorf("Failed to start server: %v", err)
return
}
logger.Infof("Server running on port %s", port)
}