From 1784f40356c104ee5eaeed781b8ccfe7910fd5c0 Mon Sep 17 00:00:00 2001 From: Ksu Date: Sat, 21 Dec 2024 03:42:55 +0300 Subject: [PATCH] image fix --- cmd/server/main.go | 2 +- internal/gateway/user/user.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index ce94017..efb6f19 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -43,7 +43,7 @@ func main() { log.Fatalf("Failed to connect to auth service: %v", err) } - userHandler, err := userHandlers.NewHandlers(conf.UserServiceAddr, appLogger) + userHandler, err := userHandlers.NewHandlers(conf.UserServiceAddr, conf.ImageServiceAddr, appLogger) if err != nil { log.Fatalf("Failed to connect to user service: %v", err) } diff --git a/internal/gateway/user/user.go b/internal/gateway/user/user.go index f51be99..069265d 100644 --- a/internal/gateway/user/user.go +++ b/internal/gateway/user/user.go @@ -10,7 +10,6 @@ import ( pbImage "kudago/internal/image/api" "kudago/internal/logger" pb "kudago/internal/user/api" - user "kudago/internal/user/api" "github.com/asaskevich/govalidator" "google.golang.org/grpc" @@ -31,14 +30,20 @@ type UserHandlers struct { logger *logger.Logger } -func NewHandlers(userServiceAddr string, logger *logger.Logger) (*UserHandlers, error) { +func NewHandlers(userServiceAddr string, imageServiceAddr string, logger *logger.Logger) (*UserHandlers, error) { authConn, err := grpc.NewClient(userServiceAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, err } + imageConn, err := grpc.NewClient(imageServiceAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return nil, err + } + return &UserHandlers{ - UserService: user.NewUserServiceClient(authConn), + UserService: pb.NewUserServiceClient(authConn), + ImageService: pbImage.NewImageServiceClient(imageConn), logger: logger, }, nil }