seperated gamemodes into seprate tables
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
f85fb7434d
commit
9dae1ca401
8 changed files with 210 additions and 17 deletions
|
@ -33,6 +33,7 @@ type Handler struct {
|
|||
func (h *Handler) Home() http.HandlerFunc {
|
||||
type data struct {
|
||||
Servers []steamServer.Server
|
||||
Gamemodes []steamServer.Gamemode
|
||||
}
|
||||
|
||||
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
||||
|
@ -43,50 +44,74 @@ func (h *Handler) Home() http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
gg, err := h.store.Gamemodes()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
tmpl.Execute(w, data {
|
||||
Servers: ss,
|
||||
Gamemodes: gg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) Europe() http.HandlerFunc {
|
||||
type data struct {
|
||||
Region string
|
||||
Servers []steamServer.Server
|
||||
Gamemodes []steamServer.Gamemode
|
||||
}
|
||||
|
||||
|
||||
|
||||
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
||||
tmpl := template.Must(template.ParseFiles("templates/region.html"))
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
reg, err := h.store.Region("Europe")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
gg, err := h.store.Gamemodes()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
ss, err := h.store.ServersByRegion(reg.ID)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
tmpl.Execute(w, data {
|
||||
Region: "Europe",
|
||||
Servers: ss,
|
||||
Gamemodes: gg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (h *Handler) America() http.HandlerFunc {
|
||||
type data struct {
|
||||
Region string
|
||||
Servers []steamServer.Server
|
||||
Gamemodes []steamServer.Gamemode
|
||||
}
|
||||
|
||||
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
||||
tmpl := template.Must(template.ParseFiles("templates/region.html"))
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
reg, err := h.store.Region("North America")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
gg, err := h.store.Gamemodes()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
ss, err := h.store.ServersByRegion(reg.ID)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -94,7 +119,10 @@ func (h *Handler) America() http.HandlerFunc {
|
|||
}
|
||||
|
||||
tmpl.Execute(w, data {
|
||||
Region: "North America",
|
||||
Servers: ss,
|
||||
Gamemodes: gg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue