dont marshal uninitialized players

This commit is contained in:
Bel LaPointe
2021-03-12 07:04:38 -06:00
parent 3efa60f2d0
commit aaf4ff3161
4 changed files with 44 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"local/router"
"local/storage"
"log"
"net/http"
"strings"
@@ -109,6 +110,9 @@ func badRequest(w http.ResponseWriter, message string) {
}
func errHandler(w http.ResponseWriter, status int, message string) {
if message == storage.ErrNotFound.Error() {
status = http.StatusNotFound
}
w.WriteHeader(status)
json.NewEncoder(w).Encode(map[string]interface{}{
"status": http.StatusText(status),