-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgui.go
73 lines (61 loc) · 1.76 KB
/
gui.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"errors"
"net/http"
)
var (
// Nodes styling definition.
// Will be applied to the JavaScript engine
groups string
)
/*
* Setup Web GUI handlers
*/
func setupGUI() error {
var err error
// Parse graph elements style groups definitions
groups, err = loadFileIntoString(config.Groups)
if err != nil {
return errors.New("Can't load groups file: " + err.Error())
}
// Load query formatting rules,
// which help to format comma/space separated indicators to a valid SQL query
err = loadFormats()
if err != nil {
return errors.New("Can't load query formatting rules: " + err.Error())
}
// Create a sessions store
err = setupSessions()
if err != nil {
return errors.New("Can't setup sessions store: " + err.Error())
}
// Parse documentation files
err = loadDocs()
if err != nil {
return errors.New("Can't load documentation: " + err.Error())
}
// Notify users about new features
err = loadFeatures()
if err != nil {
return errors.New("Can't show new features: " + err.Error())
}
// Setup the indicators upload feature
err = setupUpload()
if err != nil {
return errors.New("Can't setup the indicators upload feature: " + err.Error())
}
// Setup additional HTTPS handlers
// which are required by a Web GUI
http.HandleFunc("/", indexHandler)
http.HandleFunc("/signin", signinHandler)
http.HandleFunc("/signup", signupHandler)
http.HandleFunc("/signout", signoutHandler)
http.HandleFunc("/profile", profileHandler)
http.HandleFunc("/admin", adminHandler)
http.HandleFunc("/docs", docsHandler)
http.HandleFunc("/upload", uploadHandler)
http.HandleFunc("/download", downloadHandler)
http.HandleFunc("/ws", wsHandler)
http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("assets"))))
return nil
}