package http import ( "net/http" "hyapp/pkg/tencentrtc" "hyapp/services/gateway-service/internal/auth" "hyapp/services/gateway-service/internal/transport/http/activityapi" "hyapp/services/gateway-service/internal/transport/http/appapi" "hyapp/services/gateway-service/internal/transport/http/callbackapi" "hyapp/services/gateway-service/internal/transport/http/gameapi" "hyapp/services/gateway-service/internal/transport/http/httproutes" "hyapp/services/gateway-service/internal/transport/http/managerapi" "hyapp/services/gateway-service/internal/transport/http/messageapi" "hyapp/services/gateway-service/internal/transport/http/resourceapi" "hyapp/services/gateway-service/internal/transport/http/roomapi" "hyapp/services/gateway-service/internal/transport/http/userapi" "hyapp/services/gateway-service/internal/transport/http/walletapi" ) // Routes 把 Handler 的私有方法适配成独立路由包需要的显式 handler 表。 // 路径注册集中在 httproutes,gateway 依赖装配和鉴权 wrapper 仍留在 transport 入口层。 func (h *Handler) Routes(jwtVerifier *auth.Verifier) http.Handler { roomAPI := roomapi.New(roomapi.Config{ RoomClient: h.roomClient, RoomGuardClient: h.roomGuardClient, RoomQueryClient: h.roomQueryClient, UserProfileClient: h.userProfileClient, UserSocialClient: h.userSocialClient, WalletClient: h.walletClient, RTCTokenConfig: tencentrtc.TokenConfig{ Enabled: h.tencentRTC.Enabled, SDKAppID: h.tencentRTC.SDKAppID, SecretKey: h.tencentRTC.SecretKey, TTL: h.tencentRTC.UserSigTTL, RoomIDType: h.tencentRTC.RoomIDType, AppScene: h.tencentRTC.AppScene, }, }) walletAPI := walletapi.New(walletapi.Config{ WalletClient: h.walletClient, UserIdentityClient: h.userIdentityClient, UserProfileClient: h.userProfileClient, UserHostClient: h.userHostClient, }) userAPI := userapi.New(userapi.Config{ UserIdentityClient: h.userIdentityClient, UserProfileClient: h.userProfileClient, UserSocialClient: h.userSocialClient, UserCountryClient: h.userCountryClient, UserHostClient: h.userHostClient, WalletClient: h.walletClient, BroadcastClient: h.broadcastClient, }) messageAPI := messageapi.New(messageapi.Config{ MessageClient: h.messageClient, UserProfileClient: h.userProfileClient, }) activityAPI := activityapi.New(activityapi.Config{ TaskClient: h.taskClient, GrowthLevelClient: h.growthLevelClient, AchievementClient: h.achievementClient, WalletClient: h.walletClient, RegistrationReward: h.registrationReward, }) gameAPI := gameapi.New(gameapi.Config{ GameClient: h.gameClient, UserProfileClient: h.userProfileClient, }) resourceAPI := resourceapi.New(resourceapi.Config{ WalletClient: h.walletClient, }) managerAPI := managerapi.New(managerapi.Config{ WalletClient: h.walletClient, UserHostClient: h.userHostClient, UserProfileClient: h.userProfileClient, }) appAPI := appapi.New(appapi.Config{ AppConfigReader: h.appConfigReader, UserDeviceClient: h.userDeviceClient, ObjectUploader: h.objectUploader, }) callbackAPI := callbackapi.New(callbackapi.Config{ RoomClient: h.roomClient, RoomGuardClient: h.roomGuardClient, UserProfileClient: h.userProfileClient, TencentIM: callbackapi.TencentIMConfig{ SDKAppID: h.tencentIM.SDKAppID, AdminIdentifier: h.tencentIM.AdminIdentifier, CallbackAuthToken: h.tencentIM.CallbackAuthToken, }, TencentRTC: callbackapi.TencentRTCConfig{ SDKAppID: h.tencentRTC.SDKAppID, CallbackSignKey: h.tencentRTC.CallbackSignKey, UserSigTTL: h.tencentRTC.UserSigTTL, }, }) userHandlers := userAPI.UserHandlers() userHandlers.BatchUserProfiles = messageAPI.BatchUserProfiles userHandlers.BatchRoomDisplayProfiles = roomAPI.BatchRoomDisplayProfiles userHandlers.GetMyGiftWall = walletAPI.GetMyGiftWall userHandlers.ListMyResources = resourceAPI.ListMyResources userHandlers.EquipMyResource = resourceAPI.EquipMyResource return httproutes.New(httproutes.Config{ PublicWrap: h.publicAPIHandler, AuthWrap: func(handler http.HandlerFunc) http.Handler { return h.apiHandler(jwtVerifier, handler) }, ProfileWrap: func(handler http.HandlerFunc) http.Handler { return h.profileAPIHandler(jwtVerifier, handler) }, Auth: httproutes.AuthHandlers{ LoginPassword: h.loginPassword, SetPassword: h.setPassword, LoginThirdParty: h.loginThirdParty, RefreshToken: h.refreshToken, Logout: h.logout, }, App: httproutes.AppHandlers{ ListRegistrationCountries: userAPI.ListRegistrationCountries, ListLoginRiskBlockedCountries: userAPI.ListLoginRiskBlockedCountries, GetAppBootstrap: appAPI.GetAppBootstrap, ListH5Links: appAPI.ListH5Links, ListAppBanners: appAPI.ListAppBanners, GetAppVersion: appAPI.GetAppVersion, GetResourceGroup: resourceAPI.GetResourceGroup, ListGifts: resourceAPI.ListGifts, ListEmojiPacks: resourceAPI.ListEmojiPacks, IssueTencentIMUserSig: h.issueTencentIMUserSig, IssueTencentRTCToken: roomAPI.IssueTencentRTCToken, HandleTencentIMCallback: callbackAPI.HandleTencentIMCallback, HandleTencentRTCCallback: callbackAPI.HandleTencentRTCCallback, UploadFile: appAPI.UploadFile, UploadAvatar: appAPI.UploadAvatar, HandlePushToken: appAPI.HandlePushToken, }, User: userHandlers, Manager: managerAPI.ManagerHandlers(), Room: roomAPI.RoomHandlers(), Message: messageAPI.MessageHandlers(), Task: activityAPI.TaskHandlers(), Level: activityAPI.LevelHandlers(), Achievement: activityAPI.AchievementHandlers(), Wallet: walletAPI.WalletHandlers(), VIP: walletAPI.VIPHandlers(), Game: gameAPI.Handlers(), }) }