-
Notifications
You must be signed in to change notification settings - Fork 20
/
adminDashboard.go
52 lines (46 loc) · 1.21 KB
/
adminDashboard.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 (
"bufio"
"fmt"
"net/http"
"github.com/Symantec/Dominator/lib/html"
)
type adminDashboardType struct {
htmlWriter html.HtmlWriter
ready bool
}
func newAdminDashboard(htmlWriter html.HtmlWriter) *adminDashboardType {
return &adminDashboardType{
htmlWriter: htmlWriter,
}
}
func (dashboard *adminDashboardType) ServeHTTP(w http.ResponseWriter,
req *http.Request) {
if req.URL.Path != "/" {
http.NotFound(w, req)
return
}
writer := bufio.NewWriter(w)
defer writer.Flush()
fmt.Fprintln(writer, "<title>keymaster status page</title>")
fmt.Fprintln(writer, "<body>")
fmt.Fprintln(writer, "<center>")
fmt.Fprintln(writer, "<h1>keymaster status page</h1>")
fmt.Fprintln(writer, "</center>")
html.WriteHeaderWithRequest(writer, req)
fmt.Fprintln(writer, "<h3>")
if dashboard.ready {
fmt.Fprintln(writer,
`Keymaster is <font color="green">ready</font><br>`)
} else {
fmt.Fprintln(writer, `Keymaster is <font color="red">sealed</font><br>`)
}
dashboard.htmlWriter.WriteHtml(writer)
fmt.Fprintln(writer, "</h3>")
fmt.Fprintln(writer, "<hr>")
html.WriteFooter(writer)
fmt.Fprintln(writer, "</body>")
}
func (dashboard *adminDashboardType) setReady() {
dashboard.ready = true
}