aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 11:53:30 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 11:53:30 -0400
commit2acb97145a08f0ff7f07f95ae077e868b5bb687d (patch)
tree60060577444ebce23fc4f5b69488c617a242e614 /pkg/api
parent1178515724a4309e17046b094909673eaeeaa24b (diff)
downloadAtlas-2acb97145a08f0ff7f07f95ae077e868b5bb687d.tar.gz
Atlas-2acb97145a08f0ff7f07f95ae077e868b5bb687d.zip
pkg/api/api0: Better error messages for missing params
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/api0/playerinfo.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/api/api0/playerinfo.go b/pkg/api/api0/playerinfo.go
index cacdbd6..b47ef4c 100644
--- a/pkg/api/api0/playerinfo.go
+++ b/pkg/api/api0/playerinfo.go
@@ -79,7 +79,17 @@ func (h *Handler) handlePlayer(w http.ResponseWriter, r *http.Request) {
return
}
- uid, err := strconv.ParseUint(r.URL.Query().Get("id"), 10, 64)
+ uidQ := r.URL.Query().Get("id")
+ if uidQ == "" {
+ respJSON(w, r, http.StatusBadRequest, map[string]any{
+ "success": false,
+ "error": ErrorCode_BAD_REQUEST,
+ "msg": fmt.Sprintf("%s: id param is required", ErrorCode_BAD_REQUEST.Message()),
+ })
+ return
+ }
+
+ uid, err := strconv.ParseUint(uidQ, 10, 64)
if err != nil {
respJSON(w, r, http.StatusNotFound, map[string]any{
"success": false,