-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lool #182
base: main
Are you sure you want to change the base?
lool #182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет! Неплохо, ошибки все проверены - супер. Пару комментов рекомендую проверить / поправить, и работа будет принята!
http.Error(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
tasks[task.ID] = task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Перед этой операцией полезно добавить проверку - есть ли уже такой ID. И если да - вернуть ошибку пользователю. Иначе задача может быть перезатерта
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Логично.
precode.go
Outdated
if err != nil { | ||
fmt.Printf("Ошибка записи: %v", err) | ||
} | ||
json.NewEncoder(w).Encode(task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это здесь нужно? Стоит проверить как выглядит ответ этой ручки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласен. Можно было и через Chat GPT проверить. Сразу выдал ошибку. Глаза замылились в процессе написания)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласен. Можно было и через Chat GPT проверить. Сразу выдал ошибку. Глаза замылились в процессе написания)
Потестить через Postman лучше
} | ||
w.Header().Set("Content-Type", "application/json") | ||
w.WriteHeader(http.StatusOK) | ||
_, err = w.Write(resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Круто что проверяешь ошибки явно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Класная телега у тебя. кстати. Подписался)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Класная телега у тебя. кстати. Подписался)
Рада. Добро пожаловать!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Супер. Мелочевка осталась. Принято!
@@ -73,6 +73,11 @@ func postTask(w http.ResponseWriter, r *http.Request) { | |||
http.Error(w, err.Error(), http.StatusBadRequest) | |||
return | |||
} | |||
if _, ex := tasks[task.ID]; ex { | |||
http.Error(w, "Задача с таким ID уже существует", http.StatusConflict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Форматирование съехало, рекомендую добавить go fmt
в настройки IDE, в автозапуск при сохранении
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Форматирование съехало, рекомендую добавить
go fmt
в настройки IDE, в автозапуск при сохранении
Спасибо за фичу. Учту в следующих проектах.
@@ -99,7 +104,7 @@ func getTaskForId(w http.ResponseWriter, r *http.Request) { | |||
if err != nil { | |||
fmt.Printf("Ошибка записи: %v", err) | |||
} | |||
json.NewEncoder(w).Encode(task) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пустую строчку можно совсем убрать
No description provided.