-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (34 loc) · 916 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
package main
import (
"fmt"
"log"
"net/http"
"os"
"time"
"github.com/CyberTea0X/goauth/controllers"
"github.com/CyberTea0X/goauth/models"
// "github.com/CyberTea0X/goauth/middlewares"
"github.com/gin-gonic/gin"
)
func main() {
debug := os.Getenv("DEBUG")
if debug != "" && debug != "0" {
log.SetFlags(log.LstdFlags | log.Lshortfile)
fmt.Println("Debug log enabled")
} else {
gin.SetMode(gin.ReleaseMode)
}
config, err := models.ParseConfig("config.toml")
if err != nil {
log.Fatal(err)
}
db, err := models.SetupDatabase(&config.Database)
if err != nil {
log.Fatal(err)
}
client := &http.Client{Timeout: time.Second * time.Duration(config.App.TimeoutSeconds)}
controller := controllers.NewController(config.Tokens, config.Services, client, db)
port := config.App.Port
fmt.Println("Auth server starting on port", port)
controllers.SetupRouter(controller).Run(":" + port)
}