From 0c43a6a9ea9f57edeaffacb48d152d63254ed782 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Wed, 29 Aug 2018 18:07:45 +0200 Subject: [PATCH] ws(all): moving some code around --- crm/rest/router.go | 2 -- sam/rest/router.go | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crm/rest/router.go b/crm/rest/router.go index e98494bf4..22da00d9f 100644 --- a/crm/rest/router.go +++ b/crm/rest/router.go @@ -19,8 +19,6 @@ func MountRoutes(jwtAuth auth.TokenEncoder) func(chi.Router) { module = Module{}.New(moduleSvc, contentSvc) ) - // @todo pass jwtAuth to auth handlers (signUp) for JWT generation - // Initialize handers & controllers. return func(r chi.Router) { // Protect all _private_ routes diff --git a/sam/rest/router.go b/sam/rest/router.go index 609c37540..ab6a16d46 100644 --- a/sam/rest/router.go +++ b/sam/rest/router.go @@ -17,6 +17,14 @@ func MountRoutes(jwtAuth auth.TokenEncoder) func(chi.Router) { userSvc = service.User() ) + var ( + channel = Channel{}.New(channelSvc) + message = Message{}.New(messageSvc) + organisation = Organisation{}.New(organisationSvc) + team = Team{}.New(teamSvc) + user = User{}.New(userSvc, messageSvc) + ) + // Initialize handers & controllers. return func(r chi.Router) { handlers.NewAuth(Auth{}.New(userSvc, jwtAuth)).MountRoutes(r) @@ -25,11 +33,11 @@ func MountRoutes(jwtAuth auth.TokenEncoder) func(chi.Router) { r.Group(func(r chi.Router) { r.Use(auth.AuthenticationMiddlewareValidOnly) - handlers.NewChannel(Channel{}.New(channelSvc)).MountRoutes(r) - handlers.NewMessage(Message{}.New(messageSvc)).MountRoutes(r) - handlers.NewOrganisation(Organisation{}.New(organisationSvc)).MountRoutes(r) - handlers.NewTeam(Team{}.New(teamSvc)).MountRoutes(r) - handlers.NewUser(User{}.New(userSvc, messageSvc)).MountRoutes(r) + handlers.NewChannel(channel).MountRoutes(r) + handlers.NewMessage(message).MountRoutes(r) + handlers.NewOrganisation(organisation).MountRoutes(r) + handlers.NewTeam(team).MountRoutes(r) + handlers.NewUser(user).MountRoutes(r) }) } }