/
status.go
37 lines (34 loc) · 1007 Bytes
/
status.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
package httpd
import (
"bufio"
"fmt"
"net/http"
"github.com/Cloud-Foundations/Dominator/lib/html"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
)
func (s *state) statusHandler(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>Basic filegen server status page</title>")
fmt.Fprintln(writer, "<body>")
fmt.Fprintln(writer, "<center>")
fmt.Fprintln(writer, "<h1>Basic filegen server status page</h1>")
if !srpc.CheckTlsRequired() {
fmt.Fprintln(writer,
`<h1><font color="red">Running in insecure mode. Anyone can get your files!</font></h1>`)
}
fmt.Fprintln(writer, "</center>")
html.WriteHeaderWithRequest(writer, req)
fmt.Fprintln(writer, "<h3>")
for _, htmlWriter := range htmlWriters {
htmlWriter.WriteHtml(writer)
}
fmt.Fprintln(writer, "</h3>")
fmt.Fprintln(writer, "<hr>")
html.WriteFooter(writer)
fmt.Fprintln(writer, "</body>")
}