2026-04-30 02:30:32 +08:00

54 lines
3.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package http
import (
"net/http"
"hyapp/services/gateway-service/internal/auth"
)
const apiV1Prefix = "/api/v1"
// Routes 只维护 gateway 对外 HTTP 路径到 transport handler 的绑定。
// 业务状态和命令执行仍然全部下沉到 room-servicegateway 不在这里承载房间逻辑。
func (h *Handler) Routes(jwtVerifier *auth.Verifier) http.Handler {
mux := http.NewServeMux()
mux.Handle(apiV1Prefix+"/auth/password/login", publicAPIHandler(h.loginPassword))
mux.Handle(apiV1Prefix+"/auth/password/set", apiHandler(jwtVerifier, h.setPassword))
mux.Handle(apiV1Prefix+"/auth/third-party/login", publicAPIHandler(h.loginThirdParty))
mux.Handle(apiV1Prefix+"/auth/token/refresh", publicAPIHandler(h.refreshToken))
mux.Handle(apiV1Prefix+"/auth/logout", publicAPIHandler(h.logout))
mux.Handle(apiV1Prefix+"/countries", publicAPIHandler(h.listRegistrationCountries))
mux.Handle(apiV1Prefix+"/im/usersig", profileAPIHandler(jwtVerifier, h.issueTencentIMUserSig))
mux.Handle(apiV1Prefix+"/rtc/token", profileAPIHandler(jwtVerifier, h.issueTencentRTCToken))
mux.Handle(apiV1Prefix+"/tencent-im/callback", publicAPIHandler(h.handleTencentIMCallback))
mux.Handle(apiV1Prefix+"/users/by-display-user-id/", publicAPIHandler(h.resolveDisplayUserID))
mux.Handle(apiV1Prefix+"/users/me/identity", apiHandler(jwtVerifier, h.getMyIdentity))
mux.Handle(apiV1Prefix+"/users/me/onboarding/complete", apiHandler(jwtVerifier, h.completeMyOnboarding))
mux.Handle(apiV1Prefix+"/users/me/profile/update", profileAPIHandler(jwtVerifier, h.updateMyProfile))
mux.Handle(apiV1Prefix+"/users/me/country/change", profileAPIHandler(jwtVerifier, h.changeMyCountry))
mux.Handle(apiV1Prefix+"/users/me/display-id/change", apiHandler(jwtVerifier, h.changeMyDisplayUserID))
mux.Handle(apiV1Prefix+"/users/me/display-id/pretty/apply", apiHandler(jwtVerifier, h.applyMyPrettyDisplayUserID))
mux.Handle(apiV1Prefix+"/rooms", profileAPIHandler(jwtVerifier, h.listRooms))
mux.Handle(apiV1Prefix+"/rooms/create", profileAPIHandler(jwtVerifier, h.createRoom))
mux.Handle(apiV1Prefix+"/rooms/join", profileAPIHandler(jwtVerifier, h.joinRoom))
mux.Handle(apiV1Prefix+"/rooms/leave", profileAPIHandler(jwtVerifier, h.leaveRoom))
mux.Handle(apiV1Prefix+"/rooms/mic/up", profileAPIHandler(jwtVerifier, h.micUp))
mux.Handle(apiV1Prefix+"/rooms/mic/down", profileAPIHandler(jwtVerifier, h.micDown))
mux.Handle(apiV1Prefix+"/rooms/mic/change", profileAPIHandler(jwtVerifier, h.changeMicSeat))
mux.Handle(apiV1Prefix+"/rooms/mic/publishing/confirm", profileAPIHandler(jwtVerifier, h.confirmMicPublishing))
mux.Handle(apiV1Prefix+"/rooms/mic/lock", profileAPIHandler(jwtVerifier, h.setMicSeatLock))
mux.Handle(apiV1Prefix+"/rooms/chat/enabled", profileAPIHandler(jwtVerifier, h.setChatEnabled))
mux.Handle(apiV1Prefix+"/rooms/admin/set", profileAPIHandler(jwtVerifier, h.setRoomAdmin))
mux.Handle(apiV1Prefix+"/rooms/host/transfer", profileAPIHandler(jwtVerifier, h.transferRoomHost))
mux.Handle(apiV1Prefix+"/rooms/user/mute", profileAPIHandler(jwtVerifier, h.muteUser))
mux.Handle(apiV1Prefix+"/rooms/user/kick", profileAPIHandler(jwtVerifier, h.kickUser))
mux.Handle(apiV1Prefix+"/rooms/user/unban", profileAPIHandler(jwtVerifier, h.unbanUser))
mux.Handle(apiV1Prefix+"/rooms/gift/send", profileAPIHandler(jwtVerifier, h.sendGift))
return mux
}