-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (43 loc) · 1.45 KB
/
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
50
51
52
package main
import (
"fmt"
"os"
"github.com/cortexproject/auth-gateway/gateway"
"github.com/cortexproject/auth-gateway/middleware"
"github.com/cortexproject/auth-gateway/server"
"github.com/cortexproject/auth-gateway/utils"
"github.com/cortexproject/auth-gateway/version"
)
func main() {
fmt.Print(version.Template)
version.CheckLatest()
if len(os.Args) < 2 {
fmt.Println("No configuration file is provided")
os.Exit(1)
}
filePath := os.Args[1]
conf, err := gateway.Init(filePath)
utils.CheckErr("reading the configuration file", err)
serverConf := server.Config{
HTTPListenAddr: conf.Server.Address,
HTTPListenPort: conf.Server.Port,
HTTPMiddleware: []middleware.Interface{
gateway.NewAuthentication(&conf),
},
HTTPServerReadTimeout: conf.Server.ReadTimeout,
HTTPServerWriteTimeout: conf.Server.WriteTimeout,
HTTPServerIdleTimeout: conf.Server.IdleTimeout,
UnAuthorizedHTTPListenAddr: conf.Admin.Address,
UnAuthorizedHTTPListenPort: conf.Admin.Port,
UnAuthorizedHTTPServerReadTimeout: conf.Admin.ReadTimeout,
UnAuthorizedHTTPServerWriteTimeout: conf.Admin.WriteTimeout,
UnAuthorizedHTTPServerIdleTimeout: conf.Admin.IdleTimeout,
}
server, err := server.New(serverConf)
utils.CheckErr("initializing the server", err)
defer server.Shutdown()
gtw, err := gateway.New(&conf, server)
utils.CheckErr("initializing the gateway", err)
gtw.Start(&conf)
server.Run()
}