-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.go
35 lines (30 loc) · 859 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
package main
import (
"log"
"net/http"
)
var serverConfig *ServerConfig
func main() {
localServerConfig, err := loadConfigFile("./server.config.json")
if err != nil {
log.Fatalln("Error during loading config file:", err)
}
cred, err := loadConfigFile("./credentials.json")
if err != nil {
log.Print("Error during loading credentials file:", err)
} else {
localServerConfig.PersonalToken = cred.PersonalToken
err = localServerConfig.Check()
if err != nil {
log.Fatalf("Errors in config files:\n%v\n", err)
}
}
serverConfig = localServerConfig
mux := http.NewServeMux()
mux.HandleFunc("/", makeHandler(indexHandler))
mux.HandleFunc("/index", makeHandler(indexHandler))
mux.HandleFunc("/search/", makeHandler(searchHandler))
log.Println("Starting server on :8080...")
err = http.ListenAndServe(":8080", mux)
log.Fatal(err)
}