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

rework server for better DI #3

Open
wants to merge 1 commit into
base: rework
Choose a base branch
from
Open

rework server for better DI #3

wants to merge 1 commit into from

Conversation

brojeg
Copy link
Owner

@brojeg brojeg commented Jun 7, 2023

No description provided.

Handler: a.NewRouter(),
}

if err := http.ListenAndServeTLS(":443", "server.crt", "server.key", a.Server.Handler); err != nil && !errors.Is(err, http.ErrServerClosed) {
Copy link

Choose a reason for hiding this comment

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

Вот эти параметры лучше вынести в конфиг

server "passKeeper/internal/models/server"
)

func (a *App) CreateAccount(w http.ResponseWriter, r *http.Request) {
Copy link

Choose a reason for hiding this comment

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

А зачем ты вынес всё из контроллеров в конфиг, это немного странно
лучше создавать конфиг отдельной сущностью, потом передавать его везде где нужно(репозитории, стораджи, контроллеры) в качестве зависимости.
В целом можем обсудить как делать архитектуру на 1-1

func (a App) NewRouter() *chi.Mux {
router := chi.NewRouter()
router.Use(middleware.Recoverer)
router.Post("/api/account/register", a.CreateAccount)
Copy link

Choose a reason for hiding this comment

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

А зачем ты методы App делаешь доступными извне?

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