forked from sameerdhoot/wolweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.go
41 lines (31 loc) · 775 Bytes
/
pages.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
package main
import (
"html/template"
"io"
"log"
"net/http"
)
func renderHomePage(w http.ResponseWriter, r *http.Request) {
pageData := struct {
Devices []Device
VDir string
BCastIP string
}{
Devices: appData.Devices,
VDir: appConfig.VDir,
BCastIP: appConfig.BCastIP,
}
if appConfig.VDir == "/" {
pageData.VDir = ""
}
tmpl, _ := template.ParseFiles("index.html")
tmpl.Execute(w, pageData)
log.Println("Renedered the home page.")
}
func redirectToHomePage(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, appConfig.VDir+"/", http.StatusFound)
}
func checkHealth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
io.WriteString(w, "alive")
}