You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rogueserver/api/generic.go

72 lines
1.4 KiB
Go

12 months ago
package api
import (
"encoding/gob"
"net/http"
)
11 months ago
type Server struct {
Debug bool
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
gob.Register([]interface{}{})
gob.Register(map[string]interface{}{})
11 months ago
if s.Debug {
w.Header().Set("Access-Control-Allow-Headers", "*")
w.Header().Set("Access-Control-Allow-Methods", "*")
w.Header().Set("Access-Control-Allow-Origin", "*")
11 months ago
if r.Method == "OPTIONS" {
w.WriteHeader(http.StatusOK)
return
}
}
switch r.URL.Path {
case "/account/info":
8 months ago
s.handleAccountInfo(w, r)
11 months ago
case "/account/register":
8 months ago
s.handleAccountRegister(w, r)
11 months ago
case "/account/login":
8 months ago
s.handleAccountLogin(w, r)
11 months ago
case "/account/logout":
8 months ago
s.handleAccountLogout(w, r)
11 months ago
case "/game/playercount":
s.handlePlayerCountGet(w, r)
case "/game/titlestats":
s.handleTitleStatsGet(w, r)
case "/game/classicsessioncount":
s.handleClassicSessionCountGet(w, r)
11 months ago
case "/savedata/get":
8 months ago
s.handleSavedataGet(w, r)
11 months ago
case "/savedata/update":
8 months ago
s.handleSavedataUpdate(w, r)
11 months ago
case "/savedata/delete":
8 months ago
s.handleSavedataDelete(w, r)
case "/savedata/clear":
8 months ago
s.handleSavedataClear(w, r)
case "/daily/seed":
8 months ago
s.handleSeed(w)
case "/daily/rankings":
8 months ago
s.handleRankings(w, r)
case "/daily/rankingpagecount":
8 months ago
s.handleRankingPageCount(w, r)
11 months ago
}
}
12 months ago
// auth
type GenericAuthRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
type GenericAuthResponse struct {
Token string `json:"token"`
}