183 lines
7.4 KiB
Go
183 lines
7.4 KiB
Go
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,
|
||
UserCountryClient: h.userCountryClient,
|
||
UserRegionClient: h.userRegionClient,
|
||
UserSocialClient: h.userSocialClient,
|
||
UserHostClient: h.userHostClient,
|
||
WalletClient: h.walletClient,
|
||
GrowthLevelClient: h.growthLevelClient,
|
||
AchievementClient: h.achievementClient,
|
||
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,
|
||
RoomGuardClient: h.roomGuardClient,
|
||
RoomQueryClient: h.roomQueryClient,
|
||
UserIdentityClient: h.userIdentityClient,
|
||
UserProfileClient: h.userProfileClient,
|
||
UserHostClient: h.userHostClient,
|
||
IMGroupIDPrefix: h.tencentIM.GroupIDPrefix,
|
||
})
|
||
userAPI := userapi.New(userapi.Config{
|
||
UserIdentityClient: h.userIdentityClient,
|
||
UserProfileClient: h.userProfileClient,
|
||
UserSocialClient: h.userSocialClient,
|
||
UserCPClient: h.userCPClient,
|
||
UserCountryClient: h.userCountryClient,
|
||
UserHostClient: h.userHostClient,
|
||
WalletClient: h.walletClient,
|
||
GrowthLevelClient: h.growthLevelClient,
|
||
AchievementClient: h.achievementClient,
|
||
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,
|
||
UserProfileClient: h.userProfileClient,
|
||
RoomQueryClient: h.roomQueryClient,
|
||
WalletClient: h.walletClient,
|
||
WalletDB: h.leaderboardWalletDB,
|
||
RegistrationReward: h.registrationReward,
|
||
FirstRechargeReward: h.firstRechargeReward,
|
||
CumulativeRecharge: h.cumulativeRecharge,
|
||
SevenDayCheckIn: h.sevenDayCheckIn,
|
||
LuckyGift: h.luckyGift,
|
||
RoomTurnoverReward: h.roomTurnoverReward,
|
||
WeeklyStar: h.weeklyStar,
|
||
})
|
||
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,
|
||
GrowthLevelClient: h.growthLevelClient,
|
||
})
|
||
appAPI := appapi.New(appapi.Config{
|
||
AppConfigReader: h.appConfigReader,
|
||
UserAuthClient: h.userClient,
|
||
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,
|
||
GroupIDPrefix: h.tencentIM.GroupIDPrefix,
|
||
},
|
||
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
|
||
userHandlers.UnequipMyResource = resourceAPI.UnequipMyResource
|
||
|
||
return httproutes.New(httproutes.Config{
|
||
PublicWrap: func(handler http.HandlerFunc) http.Handler {
|
||
return h.publicAPIHandler(jwtVerifier, handler)
|
||
},
|
||
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,
|
||
QuickCreateAccount: h.quickCreateAccount,
|
||
LoginThirdParty: h.loginThirdParty,
|
||
RefreshToken: h.refreshToken,
|
||
Logout: h.logout,
|
||
},
|
||
App: httproutes.AppHandlers{
|
||
ListRegistrationCountries: userAPI.ListRegistrationCountries,
|
||
ListLoginRiskBlockedCountries: userAPI.ListLoginRiskBlockedCountries,
|
||
GetAppBootstrap: appAPI.GetAppBootstrap,
|
||
ListH5Links: appAPI.ListH5Links,
|
||
ListExploreTabs: appAPI.ListExploreTabs,
|
||
ListAppBanners: appAPI.ListAppBanners,
|
||
GetAppVersion: appAPI.GetAppVersion,
|
||
GetResourceGroup: resourceAPI.GetResourceGroup,
|
||
ListResourceShopItems: resourceAPI.ListResourceShopItems,
|
||
PurchaseResourceShopItem: resourceAPI.PurchaseResourceShopItem,
|
||
ListGifts: resourceAPI.ListGifts,
|
||
ListGiftTabs: resourceAPI.ListGiftTabs,
|
||
ListEmojiPacks: resourceAPI.ListEmojiPacks,
|
||
IssueTencentIMUserSig: h.issueTencentIMUserSig,
|
||
IssueTencentRTCToken: roomAPI.IssueTencentRTCToken,
|
||
HandleTencentIMCallback: callbackAPI.HandleTencentIMCallback,
|
||
HandleTencentRTCCallback: callbackAPI.HandleTencentRTCCallback,
|
||
UploadFile: appAPI.UploadFile,
|
||
UploadAvatar: appAPI.UploadAvatar,
|
||
ProxyEffectMedia: appAPI.ProxyEffectMedia,
|
||
HandlePushToken: appAPI.HandlePushToken,
|
||
AppHeartbeat: appAPI.AppHeartbeat,
|
||
},
|
||
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(),
|
||
})
|
||
}
|