basic flag support

This commit is contained in:
Philipp 2021-09-23 15:58:56 +02:00
parent 8c56389991
commit 19e94f036e
11 changed files with 134 additions and 151 deletions

View file

@ -32,8 +32,10 @@ type Handler struct {
func (h *Handler) Home() http.HandlerFunc {
type data struct {
Region string
Servers []steamServer.Server
Gamemodes []steamServer.Gamemode
Flags []steamServer.Flag
}
tmpl := template.Must(template.ParseFiles("templates/home.html"))
@ -49,9 +51,17 @@ func (h *Handler) Home() http.HandlerFunc {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
ff, err := h.store.Flags()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
tmpl.Execute(w, data {
Region: "All Regions - Serverlist",
Servers: ss,
Gamemodes: gg,
Flags: ff,
})
}
}
@ -61,9 +71,10 @@ func (h *Handler) Europe() http.HandlerFunc {
Region string
Servers []steamServer.Server
Gamemodes []steamServer.Gamemode
Flags []steamServer.Flag
}
tmpl := template.Must(template.ParseFiles("templates/region.html"))
tmpl := template.Must(template.ParseFiles("templates/home.html"))
return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("Europe")
if err != nil {
@ -81,11 +92,17 @@ func (h *Handler) Europe() http.HandlerFunc {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
ff, err := h.store.Flags()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
tmpl.Execute(w, data {
Region: "Europe",
Servers: ss,
Gamemodes: gg,
Flags: ff,
})
}
}
@ -97,9 +114,10 @@ func (h *Handler) America() http.HandlerFunc {
Region string
Servers []steamServer.Server
Gamemodes []steamServer.Gamemode
Flags []steamServer.Flag
}
tmpl := template.Must(template.ParseFiles("templates/region.html"))
tmpl := template.Must(template.ParseFiles("templates/home.html"))
return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("North America")
if err != nil {
@ -118,10 +136,16 @@ func (h *Handler) America() http.HandlerFunc {
return
}
ff, err := h.store.Flags()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
tmpl.Execute(w, data {
Region: "North America",
Servers: ss,
Gamemodes: gg,
Flags: ff,
})
}
}