generated from VLADIMIR/template
fix
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"crypto/subtle"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -41,11 +42,16 @@ func TeamRegistrationHandler(token string, register func(context.Context, int, s
|
||||
decoder.DisallowUnknownFields()
|
||||
var registration game_service.Registration
|
||||
if err := decoder.Decode(®istration); err != nil {
|
||||
fail(http.StatusBadRequest, "Некорректный JSON регистрации")
|
||||
fail(http.StatusBadRequest, fmt.Sprintf("Некорректный JSON регистрации: %v", err))
|
||||
return
|
||||
}
|
||||
if err := decoder.Decode(new(any)); err != io.EOF {
|
||||
fail(http.StatusBadRequest, "Ожидается один JSON-объект")
|
||||
var extra any
|
||||
if err := decoder.Decode(&extra); err != io.EOF {
|
||||
if err == nil {
|
||||
fail(http.StatusBadRequest, "Некорректный JSON регистрации: после объекта обнаружены лишние данные")
|
||||
} else {
|
||||
fail(http.StatusBadRequest, fmt.Sprintf("Некорректный JSON регистрации: после объекта обнаружены лишние данные: %v", err))
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 4*time.Second)
|
||||
|
||||
Reference in New Issue
Block a user