package main import ( "html/template" "net/http" "riedstra.dev/mitch/steam-export/steam" ) var ( Templ = template.Must(template.New("index").Parse(`
Currently Downloading from: {{.Info.Url}}
{{ end }}
{{ if .Info.Error }}
Error {{.Info.Error}} Downloading from: {{.Info.Url}}
{{ end }}
Installed games: Tip: You can right click and save link as to specify a save location, e.g. an external hard drive
Note that You can also give someone a URL to install a game if they're running
this program, e.g.
http://127.0.0.1:8899/install?uri=http://my-server-ip-or-hostname/download/My Game
{{.Version}}
`))
)
func index(w http.ResponseWriter, r *http.Request) {
libMu.RLock()
defer libMu.RUnlock()
status.m.RLock()
defer status.m.RUnlock()
err := Templ.ExecuteTemplate(w, "index",
struct {
Lib *steam.Library
Info *statusInfo
Version string
}{Lib, status.s, Version})
if err != nil {
Logger.Printf("While Rendering template: %s", err)
}
Logger.Printf("Client %s Index page", r.RemoteAddr)
}