15357fd3c0
yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarbacreate and moove into new directories for BegushiyBashkir and yalarba
21 lines
541 B
Go
21 lines
541 B
Go
// pkg/utils/response.go (дополнение)
|
|
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// RespondWithValidationError отправляет ответ с ошибками валидации
|
|
func RespondWithValidationError(w http.ResponseWriter, validationError error) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
|
|
response := map[string]interface{}{
|
|
"error": "Validation failed",
|
|
"details": GetValidationErrors(validationError),
|
|
}
|
|
|
|
json.NewEncoder(w).Encode(response)
|
|
}
|