-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (35 loc) · 970 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
46
package main
import (
"math/rand"
"net/http"
"os"
"projekat/config"
"projekat/db"
"projekat/handler"
"projekat/logger"
"time"
"github.com/gorilla/context"
)
func main() {
var err error
rand.Seed(time.Now().UTC().UnixNano())
logger.Init(os.Stdout, os.Stdout, os.Stderr)
logger.Info("Initializing config")
_, err = config.InitConfig("server", nil)
if err != nil {
logger.Error("Could not initialize config: %v\n", err)
return
}
logger.Info("Initializing database")
err = db.InitializeDb()
if err != nil {
logger.Error("Could not access database: %v\n", err)
return
}
http.HandleFunc("/auth/", handler.HandleAuthorized)
http.HandleFunc("/login", handler.Login)
http.HandleFunc("/logout", handler.Logout)
http.HandleFunc("/testingHash", handler.HandleTestingHash)
logger.Info("Server listening on " + config.GetHTTPServerAddress())
http.ListenAndServe(config.GetHTTPServerAddress(), context.ClearHandler(http.DefaultServeMux))
}