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
10
cmd/main.go
10
cmd/main.go
|
@ -22,7 +22,7 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
dsn := "postgres://postgres:secret@postgres:5432/postgres?sslmode=disable"
|
dsn := "postgres://postgres:secret@u0k.de:5432/postgres?sslmode=disable"
|
||||||
|
|
||||||
store, err := postgres.NewStore(dsn)
|
store, err := postgres.NewStore(dsn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -32,13 +32,13 @@ func main() {
|
||||||
|
|
||||||
ss, err := store.Servers()
|
ss, err := store.Servers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("There is no server in the list.")
|
log.Fatal("There is an issue with the databse: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range ss {
|
for _, s := range ss {
|
||||||
serverString := s.ServerIP
|
serverString := s.ServerIP
|
||||||
c := cron.New()
|
c := cron.New()
|
||||||
c.AddFunc("*/5 * * * *", func() { updateServers(serverString, store) })
|
c.AddFunc("*/1 * * * *", func() { updateServers(serverString, store) })
|
||||||
c.Start()
|
c.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +48,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateServers(serverString string, store steamServer.Store) {
|
func updateServers(serverString string, store steamServer.Store) {
|
||||||
url := "http://steam-server-api:8080/server/" + serverString
|
url := "http://localhost:8090/server/" + serverString
|
||||||
|
|
||||||
reqClient := http.Client {
|
reqClient := http.Client {
|
||||||
Timeout: time.Second * 2,
|
Timeout: time.Second * 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
|
|
29
postgres/gamemode_store.go
Normal file
29
postgres/gamemode_store.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package postgres
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.snrd.de/Spaenny/steamServer"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GamemodeStore struct {
|
||||||
|
*sqlx.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *GamemodeStore) Gamemode(name string) (steamServer.Gamemode, error) {
|
||||||
|
var g steamServer.Gamemode
|
||||||
|
if err := s.Get(&g, `SELECT * FROM gamemodes WHERE name = $1`, name); err != nil {
|
||||||
|
return steamServer.Gamemode{}, fmt.Errorf("error getting gamemode id: %w", err)
|
||||||
|
}
|
||||||
|
return g, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *GamemodeStore) Gamemodes() ([]steamServer.Gamemode, error) {
|
||||||
|
var gg []steamServer.Gamemode
|
||||||
|
var query = `SELECT * FROM gamemodes ORDER BY name ASC`
|
||||||
|
if err := s.Select(&gg, query); err != nil {
|
||||||
|
return []steamServer.Gamemode{}, fmt.Errorf("error gettings servers: %w", err)
|
||||||
|
}
|
||||||
|
return gg, nil
|
||||||
|
}
|
|
@ -39,6 +39,15 @@ func (s *ServerStore) ServersByRegion(regionID uuid.UUID) ([]steamServer.Server,
|
||||||
return ss, nil
|
return ss, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServerStore) ServersByRegionAndGamemode(regionID uuid.UUID, gamemodeID uuid.UUID) ([]steamServer.Server, error) {
|
||||||
|
var ss []steamServer.Server
|
||||||
|
var query = `SELECT * FROM servers WHERE gamemode_id = $1 AND region_id = $2`
|
||||||
|
if err := s.Select(&ss, query, regionID, gamemodeID); err != nil {
|
||||||
|
return []steamServer.Server{}, fmt.Errorf("error gettings region servers: %w", err)
|
||||||
|
}
|
||||||
|
return ss, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ServerStore) ServersByGamemode(gamemodeID uuid.UUID) ([]steamServer.Server, error) {
|
func (s *ServerStore) ServersByGamemode(gamemodeID uuid.UUID) ([]steamServer.Server, error) {
|
||||||
var ss []steamServer.Server
|
var ss []steamServer.Server
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ func NewStore(dataSourceName string) (*Store, error) {
|
||||||
return &Store {
|
return &Store {
|
||||||
ServerStore: &ServerStore{DB: db},
|
ServerStore: &ServerStore{DB: db},
|
||||||
RegionStore: &RegionStore{DB: db},
|
RegionStore: &RegionStore{DB: db},
|
||||||
|
GamemodeStore: &GamemodeStore{DB: db},
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,5 +29,6 @@ func NewStore(dataSourceName string) (*Store, error) {
|
||||||
type Store struct {
|
type Store struct {
|
||||||
*ServerStore
|
*ServerStore
|
||||||
*RegionStore
|
*RegionStore
|
||||||
|
*GamemodeStore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package steamServer
|
package steamServer
|
||||||
|
|
||||||
import "github.com/google/uuid"
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
ID uuid.UUID `db:"id"`
|
ID uuid.UUID `db:"id"`
|
||||||
|
@ -19,10 +21,16 @@ type Region struct {
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Gamemode struct {
|
||||||
|
ID uuid.UUID `db:"id"`
|
||||||
|
Name string `db:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
type ServerStore interface {
|
type ServerStore interface {
|
||||||
Server(id uuid.UUID) (Server, error)
|
Server(id uuid.UUID) (Server, error)
|
||||||
Servers() ([]Server, error)
|
Servers() ([]Server, error)
|
||||||
ServersByRegion(regionID uuid.UUID) ([]Server, error)
|
ServersByRegion(regionID uuid.UUID) ([]Server, error)
|
||||||
|
ServersByRegionAndGamemode(regionID uuid.UUID, gamemodeID uuid.UUID) ([]Server, error)
|
||||||
ServersByGamemode(gamemodeID uuid.UUID) ([]Server, error)
|
ServersByGamemode(gamemodeID uuid.UUID) ([]Server, error)
|
||||||
CreateServer(ser *Server) error
|
CreateServer(ser *Server) error
|
||||||
UpdateServerByQuery(ser *Server, server_ip string) error
|
UpdateServerByQuery(ser *Server, server_ip string) error
|
||||||
|
@ -32,7 +40,14 @@ type RegionStore interface {
|
||||||
Region(name string) (Region, error)
|
Region(name string) (Region, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type GamemodeStore interface {
|
||||||
|
Gamemode(name string) (Gamemode, error)
|
||||||
|
Gamemodes() ([]Gamemode, error)
|
||||||
|
}
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
ServerStore
|
ServerStore
|
||||||
RegionStore
|
RegionStore
|
||||||
|
GamemodeStore
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
</head>
|
</head>
|
||||||
<body class="h-screen overflow-hidden flex items-center justify-center" style="background: #edf2f7;">
|
<body class="h-screen overflow-hidden flex items-center justify-center" style="background: #edf2f7;">
|
||||||
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
|
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="/" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">All Regions</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div class="p-2 md:w-40">
|
<div class="p-2 md:w-40">
|
||||||
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
<div>
|
<div>
|
||||||
|
@ -35,19 +42,21 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ $gamemodes := .Gamemodes}}
|
||||||
|
{{ $servers := .Servers}}
|
||||||
<div class="container mx-auto px-4 sm:px-8">
|
<div class="container mx-auto px-4 sm:px-8">
|
||||||
<div class="py-8">
|
<div class="py-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-2xl font-semibold leading-tight">Serverlist</h2>
|
<h2 class="text-2xl font-semibold leading-tight">Serverlist</h2>
|
||||||
</div>
|
</div>
|
||||||
|
{{range $gamemode := $gamemodes}}
|
||||||
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
||||||
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
|
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
|
||||||
<table class="min-w-full leading-normal">
|
<table class="min-w-full leading-normal">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||||
Servername
|
{{$gamemode.Name}}
|
||||||
</th>
|
</th>
|
||||||
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||||
Map
|
Map
|
||||||
|
@ -59,27 +68,30 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{range .Servers}}
|
{{range $server := $servers}}
|
||||||
|
{{if eq $gamemode.ID $server.GamemodeID}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="ml-3">
|
<div class="ml-3">
|
||||||
<a href="steam://connect/{{.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{.Name}}</a>
|
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
<p class="text-gray-900 whitespace-no-wrap">{{.Map}}</p>
|
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
<p class="text-gray-900 whitespace-no-wrap">{{.Players}}/{{.MaxPlayers}}</p>
|
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
98
templates/region.html
Normal file
98
templates/region.html
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
<html lang="en"><head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://unpkg.com/tailwindcss@1.0.4/dist/tailwind.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body class="h-screen overflow-hidden flex items-center justify-center" style="background: #edf2f7;">
|
||||||
|
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="/" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">All Regions</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">North America</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="/europe" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">Europe</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="#" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">Australia</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="p-2 md:w-40">
|
||||||
|
<a href="#" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
|
||||||
|
<div>
|
||||||
|
<p class=" text-xs font-medium ">Asia</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ $gamemodes := .Gamemodes}}
|
||||||
|
{{ $servers := .Servers}}
|
||||||
|
<div class="container mx-auto px-4 sm:px-8">
|
||||||
|
<div class="py-8">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-semibold leading-tight">{{.Region}}</h2>
|
||||||
|
</div>
|
||||||
|
{{range $gamemode := $gamemodes}}
|
||||||
|
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
|
||||||
|
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
|
||||||
|
<table class="min-w-full leading-normal">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||||
|
{{$gamemode.Name}}
|
||||||
|
</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||||
|
Map
|
||||||
|
</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||||
|
Players
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range $server := $servers}}
|
||||||
|
{{if eq $gamemode.ID $server.GamemodeID}}
|
||||||
|
<tr>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="ml-3">
|
||||||
|
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
|
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||||
|
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -33,6 +33,7 @@ type Handler struct {
|
||||||
func (h *Handler) Home() http.HandlerFunc {
|
func (h *Handler) Home() http.HandlerFunc {
|
||||||
type data struct {
|
type data struct {
|
||||||
Servers []steamServer.Server
|
Servers []steamServer.Server
|
||||||
|
Gamemodes []steamServer.Gamemode
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
||||||
|
@ -43,26 +44,38 @@ func (h *Handler) Home() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gg, err := h.store.Gamemodes()
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
tmpl.Execute(w, data {
|
tmpl.Execute(w, data {
|
||||||
Servers: ss,
|
Servers: ss,
|
||||||
|
Gamemodes: gg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) Europe() http.HandlerFunc {
|
func (h *Handler) Europe() http.HandlerFunc {
|
||||||
type data struct {
|
type data struct {
|
||||||
|
Region string
|
||||||
Servers []steamServer.Server
|
Servers []steamServer.Server
|
||||||
|
Gamemodes []steamServer.Gamemode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpl := template.Must(template.ParseFiles("templates/region.html"))
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("templates/home.html"))
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
reg, err := h.store.Region("Europe")
|
reg, err := h.store.Region("Europe")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gg, err := h.store.Gamemodes()
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
ss, err := h.store.ServersByRegion(reg.ID)
|
ss, err := h.store.ServersByRegion(reg.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -70,23 +83,35 @@ func (h *Handler) Europe() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl.Execute(w, data {
|
tmpl.Execute(w, data {
|
||||||
|
Region: "Europe",
|
||||||
Servers: ss,
|
Servers: ss,
|
||||||
|
Gamemodes: gg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (h *Handler) America() http.HandlerFunc {
|
func (h *Handler) America() http.HandlerFunc {
|
||||||
type data struct {
|
type data struct {
|
||||||
|
Region string
|
||||||
Servers []steamServer.Server
|
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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
reg, err := h.store.Region("North America")
|
reg, err := h.store.Region("North America")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gg, err := h.store.Gamemodes()
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
ss, err := h.store.ServersByRegion(reg.ID)
|
ss, err := h.store.ServersByRegion(reg.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -94,7 +119,10 @@ func (h *Handler) America() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl.Execute(w, data {
|
tmpl.Execute(w, data {
|
||||||
|
Region: "North America",
|
||||||
Servers: ss,
|
Servers: ss,
|
||||||
|
Gamemodes: gg,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue