Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyKomarovCoder committed Dec 24, 2023
2 parents c3c9715 + 803f85c commit e5ed76e
Show file tree
Hide file tree
Showing 10 changed files with 501 additions and 307 deletions.
8 changes: 6 additions & 2 deletions cmd/api/init/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
sessionRep "github.com/go-park-mail-ru/2023_2_Hamster/internal/monolithic/sessions/repository/redis"
sessionUsecase "github.com/go-park-mail-ru/2023_2_Hamster/internal/monolithic/sessions/usecase"

iohub "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/IOhub/delivery/http"

"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -101,18 +103,20 @@ func Init(db *pgxpool.Pool, redis *redis.Client, log *logger.Logger) *mux.Router
csrfMiddlewear := middleware.NewCSRFMiddleware(csrfUsecase, *log)

userHandler := userDelivery.NewHandler(userUsecase, *log)
transactionHandler := transactionDelivery.NewHandler(transactionUsecase, userUsecase, accountClient, *log)
transactionHandler := transactionDelivery.NewHandler(transactionUsecase, *log)

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / linter

not enough arguments in call to transactionDelivery.NewHandler

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / test

not enough arguments in call to transactionDelivery.NewHandler

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / linter

not enough arguments in call to transactionDelivery.NewHandler

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / lint_and_test

not enough arguments in call to transactionDelivery.NewHandler

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / lint_and_test

not enough arguments in call to transactionDelivery.NewHandler

Check failure on line 106 in cmd/api/init/app/init.go

View workflow job for this annotation

GitHub Actions / test

not enough arguments in call to transactionDelivery.NewHandler
categoryHandler := categoryDelivary.NewHandler(categortClient, *log)
csrfHandler := csrfDelivery.NewHandler(csrfUsecase, *log)
accountHandler := accountDelivery.NewHandler(accountClient, *log)
iohubHandler := iohub.NewHandler(transactionUsecase, userUsecase, categortClient, accountClient, *log)

return router.InitRouter(
authHandler,
userHandler,
transactionHandler,
categoryHandler,
csrfHandler,
accountHandler,
iohubHandler,
csrfHandler,
logMiddlewear,
recoveryMiddlewear,
authMiddlewear,
Expand Down
30 changes: 23 additions & 7 deletions cmd/api/init/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
_ "github.com/go-park-mail-ru/2023_2_Hamster/docs"
"github.com/prometheus/client_golang/prometheus/promhttp"

iohub "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/IOhub/delivery/http"
account "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/account/delivery/http"
auth "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/auth/delivery/http"
category "github.com/go-park-mail-ru/2023_2_Hamster/internal/microservices/category/delivery/http"
Expand All @@ -26,12 +27,14 @@ func InitRouter(auth *auth.Handler,
user *user.Handler,
transaction *transaction.Handler,
category *category.Handler,
csrf *csrf.Handler,
account *account.Handler,
iohub *iohub.Handler,
csrf *csrf.Handler,
logMid *middleware.LoggingMiddleware,
recoveryMid *middleware.RecoveryMiddleware,
authMid *middleware.AuthMiddleware,
csrfMid *middleware.CSRFMiddleware) *mux.Router {
csrfMid *middleware.CSRFMiddleware,
) *mux.Router {

r := mux.NewRouter()
r.Use(middleware.RequestID)
Expand Down Expand Up @@ -102,14 +105,16 @@ func InitRouter(auth *auth.Handler,
transactionRouter.Use(authMid.Authentication)
transactionRouter.Use(csrfMid.CheckCSRF)
{
transactionRouter.Methods("GET").Path("/export").HandlerFunc(transaction.ExportTransactions)
transactionRouter.Methods("GET").Path("/feed").HandlerFunc(transaction.GetFeed)
transactionRouter.Methods("GET").Path("/count").HandlerFunc(transaction.GetCount)
// transactionRouter.Methods("GET").Path("/{transaction_id}/").HandlerFunc(transaction.Get)
transactionRouter.Methods("PUT").Path("/update").HandlerFunc(transaction.Update)
transactionRouter.Methods("POST").Path("/create").HandlerFunc(transaction.Create)
transactionRouter.Methods("PUT").Path("/update").HandlerFunc(transaction.Update)
transactionRouter.Methods("DELETE").Path("/{transaction_id}/delete").HandlerFunc(transaction.Delete)
transactionRouter.Methods("POST").Path("/import").HandlerFunc(transaction.ImportTransactions)
transactionRouter.Methods("GET").Path("/feed").HandlerFunc(transaction.GetFeed)

transactionRouter.Methods("GET").Path("/count").HandlerFunc(transaction.GetCount)

transactionRouter.Methods("GET").Path("/export").HandlerFunc(iohub.ExportTransactions)
transactionRouter.Methods("POST").Path("/import").HandlerFunc(iohub.ImportTransactions)
}

categoryRouter := apiRouter.PathPrefix("/tag").Subrouter()
Expand All @@ -121,5 +126,16 @@ func InitRouter(auth *auth.Handler,
categoryRouter.Methods("PUT").Path("/{tagID}/update").HandlerFunc(category.UpdateTag)
categoryRouter.Methods("DELETE").Path("/delete").HandlerFunc(category.DeleteTag)
}

goalsRouter := userRouter.PathPrefix("/goal").Subrouter()
// goalsRouter.Use(authMid.Authentication)
// goalsRouter.Use(csrfMid.CheckCSRF)
{
goalsRouter.Methods("GET").Path("/")
goalsRouter.Methods("POST").Path("/add")
goalsRouter.Methods("PUT").Path("/update")
goalsRouter.Methods("DELETE").Path("/delete")
}

return r
}
4 changes: 4 additions & 0 deletions internal/common/http/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ func GetIpFromRequest(r *http.Request) (string, error) {

return "", errors.New("IP not found")
}

func GetGoalIdFromRequest(r *http.Request) {
return

Check failure on line 131 in internal/common/http/request_handler.go

View workflow job for this annotation

GitHub Actions / lint_and_test

S1023: redundant `return` statement (gosimple)
}
Loading

0 comments on commit e5ed76e

Please sign in to comment.