Handlers, DB, Cache

This commit is contained in:
2026-03-10 19:17:43 +03:00
parent e56b1f1305
commit 968c030939
23 changed files with 566 additions and 34 deletions

View File

@@ -11,6 +11,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/fx"
"payouts/internal/api/payment"
"payouts/internal/api/user"
"payouts/internal/api/version"
appConfig "payouts/internal/config"
"payouts/internal/service/monitoring"
@@ -18,8 +20,11 @@ import (
// Module is a fx module
var Module = fx.Options(
user.Module,
payment.Module,
version.Module,
monitoring.Module,
fx.Invoke(RegisterRoutes),
)
@@ -32,7 +37,9 @@ type Params struct {
AppConfig *appConfig.App
Version version.Handler
PaymentHandler payment.Handler
UserHandler user.Handler
Version version.Handler
Metrics monitoring.Metrics
}
@@ -54,11 +61,16 @@ func RegisterRoutes(p Params, lc fx.Lifecycle) {
}
apiRouter := router.PathPrefix(BaseRoute).Subrouter()
apiRouter.HandleFunc("/test", func(http.ResponseWriter, *http.Request) {
slog.Info("Test called", slog.String("sample", "value"))
})
// data
userRouter := apiRouter.PathPrefix(user.BaseRoute).Subrouter()
userRouter.HandleFunc(user.RegisterRoute, p.UserHandler.UserRegister).Methods(http.MethodPost)
userRouter.HandleFunc(user.LoginRoute, p.UserHandler.UserLogin).Methods(http.MethodPost)
paymentRouter := apiRouter.PathPrefix(payment.BaseRoute).Subrouter()
paymentRouter.HandleFunc(payment.CreateRoute, p.PaymentHandler.PaymentCreate).Methods(http.MethodPost)
paymentRouter.HandleFunc(payment.CallbackRoute, p.PaymentHandler.PaymentCallback).Methods(http.MethodPost)
// collect api metrics
apiRouter.Use(p.Metrics.GetMiddleware())
router.Handle(p.AppConfig.Metrics.Endpoint, promhttp.Handler())