Skip to content

Conversation

@TOsmanov
Copy link
Owner

@TOsmanov TOsmanov commented May 18, 2024

For use, run:

docker compose up

after open in browser http://127.0.0.1:10001

@TOsmanov TOsmanov changed the title Add qr gen Add QR-generator May 18, 2024
@TOsmanov TOsmanov force-pushed the add-qr-gen branch 2 times, most recently from d1d9972 to 9c98986 Compare May 21, 2024 16:19
@TOsmanov TOsmanov force-pushed the add-qr-gen branch 2 times, most recently from 54eda0e to aa58aba Compare May 21, 2024 17:21
@TOsmanov TOsmanov force-pushed the add-qr-gen branch 2 times, most recently from e1f4fac to c8145a6 Compare May 27, 2024 16:01
Copy link

@vladislavmass vladislavmass left a 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"))

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")

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 {

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))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По сути это функционал сервера статики. Такая обработка имеет смысл только если мы хотим динамический заполнять шаблон

@TOsmanov TOsmanov changed the title Add QR-generator [WIP] Add QR-generator May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants