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.

28 lines
561 B
Go

package api
import (
"encoding/json"
"fmt"
"net/http"
"github.com/Flashfyre/pokerogue-server/db"
)
// /game/playercount - get player count
func (s *Server) HandlePlayerCountGet(w http.ResponseWriter, r *http.Request) {
playerCount, err := db.FetchPlayerCount()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
response, err := json.Marshal(playerCount)
if err != nil {
http.Error(w, fmt.Sprintf("failed to marshal response json: %s", err), http.StatusInternalServerError)
return
}
w.Write(response)
}