-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Add QR-generator #1
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
base: main
Are you sure you want to change the base?
Conversation
d1d9972 to
9c98986
Compare
54eda0e to
aa58aba
Compare
e1f4fac to
c8145a6
Compare
vladislavmass
left a comment
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.
Хорошая работа. Принято. Проект действительно теперь работает без явных паник и просто ошибок. Из минусов проекта могу отметить следующее
1)Нет четкого разделения на слои. По сути все работа идет в веб хэндлерах
2)Нет интеграционных тестов
3) Используется шаблонизатора, хотя он тут не нужен
| func Index(log *slog.Logger, w http.ResponseWriter, | ||
| _ *http.Request, | ||
| ) { | ||
| tpl := template.Must(template.ParseFiles("site/index.html")) |
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.
Два вопроса по этому месту. Почему мы с этим работаем как с шаблоном, а не со статикой? И почему мы на каждый запрос читаем файл, а не прочитали его один раз и положили в мапу?
| r *http.Request, | ||
| ) { | ||
| const op = "handlers.OrderHandler.GetPreview" | ||
| buf, err := os.ReadFile("site/preview.jpg") |
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.
Теже 2 вопроса что и выше
| log.Info("Starting server", slog.String("address", srv.Addr)) | ||
|
|
||
| go func() { | ||
| if err = srv.ListenAndServe(); err != nil { |
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.
Подумайте что произойдет если тут будет ошибка. По текущей логике когда ошибка выведится потом будет написано что севере успешно запущен и после этого будет идти ожидание сигналы от системы. Обычно при ошибке дергается cancel
| func Index(log *slog.Logger, w http.ResponseWriter, | ||
| _ *http.Request, cfg *config.Config, | ||
| ) { | ||
| tpl := template.Must(template.ParseFiles(cfg.MainPage)) |
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.
По сути это функционал сервера статики. Такая обработка имеет смысл только если мы хотим динамический заполнять шаблон
For use, run:
after open in browser http://127.0.0.1:10001