-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
51 lines (43 loc) · 1.29 KB
/
server.go
File metadata and controls
51 lines (43 loc) · 1.29 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
49
50
51
package main
import (
srvConfig "github.com/CHESSComputing/golib/config"
ldap "github.com/CHESSComputing/golib/ldap"
server "github.com/CHESSComputing/golib/server"
"github.com/CHESSComputing/golib/services"
"github.com/gin-gonic/gin"
)
// Verbose defines verbosity level
var Verbose int
// keep ldap cache
var ldapCache *ldap.Cache
// global variables
var _foxdenUser services.UserAttributes
// helper function to setup our router
func setupRouter() *gin.Engine {
routes := []server.Route{
{Method: "GET", Path: "/translate", Handler: GetHandler, Authorized: false},
}
r := server.Router(routes, nil, "static", srvConfig.Config.ClasseInfoData.WebServer)
return r
}
// Server defines our HTTP server
func Server() {
// init Verbose
Verbose = srvConfig.Config.ClasseInfoData.WebServer.Verbose
// initialize ldap cache
ldapCache = &ldap.Cache{Map: make(map[string]ldap.Entry)}
// make a choice of foxden user
switch srvConfig.Config.ClasseInfoData.FoxdenUser.User {
case "Maglab":
_foxdenUser = &services.MaglabUser{}
case "CHESS":
_foxdenUser = &services.CHESSUser{}
default:
_foxdenUser = &services.CHESSUser{}
}
_foxdenUser.Init()
// setup web router and start the service
r := setupRouter()
webServer := srvConfig.Config.ClasseInfoData.WebServer
server.StartServer(r, webServer)
}