Skip to content
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

Iter23 #22

Merged
merged 22 commits into from
Apr 17, 2024
Merged

Iter23 #22

merged 22 commits into from
Apr 17, 2024

Conversation

The-Gleb
Copy link
Owner

  • Add asymmetric encryption
  • Add parsing config from json
  • Graceful shutdown on SIGTERM,SIGQUIT,SIGINT

@The-Gleb
Copy link
Owner Author

Не понимаю, как правильно установить поле restore в конфиге
cmd/server/config.go:78

return b
}

// TODO: it is unclear wether 'false' returned by -r flag is default or it was set by flag.
Copy link

Choose a reason for hiding this comment

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

Существует несколько подходов к решению этой проблемы:

  1. Анмаршалить bool в json.RawMessage (https://pkg.go.dev/encoding/json#RawMessage) и проверять его
  2. использовать какую-то библиотеку типа mergo, которая под капотом также анмаршалит сообщение в несколько проходов
  3. перевернуть флаг (передавать noRestore вместо restore)

Кажется, что первый вариант наиболее адекватен в данном случае


err = env.Parse(&builder.config)
if err != nil {
log.Fatal(err)
Copy link

Choose a reason for hiding this comment

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

Не стоит вызывать Fatal из глубины кода: лучше прокинуть ошибку наверх и вызвать из main

Copy link

Choose a reason for hiding this comment

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

Это не стоит пушить в репо

Copy link

Choose a reason for hiding this comment

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

Это не стоит пушить в репо


func NewDecryptionMiddleware(path string) *decryptionMiddleware {
if path == "" {
logger.Log.Info("path to private key is empty")
Copy link

Choose a reason for hiding this comment

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

Если логировать это на уровне Info, то лог будет забиваться очень быстро. Наверное, стоит выбрать Debug

http.Error(rw, err.Error(), http.StatusInternalServerError)
return
}
// logger.Log.Debugf("request body is %s", string(cipher))
Copy link

Choose a reason for hiding this comment

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

deadcode

server Outdated
Copy link

Choose a reason for hiding this comment

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

Это не надо пушить

@The-Gleb The-Gleb merged commit dfde47f into main Apr 17, 2024
4 checks passed
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.

2 participants