mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
discov
This commit is contained in:
parent
b64f621b40
commit
0a71526698
@ -16,8 +16,8 @@ import (
|
|||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
|
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
|
||||||
zk.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) // 默认RPC中间件
|
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) // 默认RPC中间件
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
//f, _ := os.Create("../logs/api.log")
|
//f, _ := os.Create("../logs/api.log")
|
||||||
//gin.DefaultWriter = io.MultiWriter(f)
|
//gin.DefaultWriter = io.MultiWriter(f)
|
||||||
@ -37,7 +37,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
}
|
}
|
||||||
userRouterGroup := r.Group("/user")
|
userRouterGroup := r.Group("/user")
|
||||||
{
|
{
|
||||||
u := NewUser(zk)
|
u := NewUser(discov)
|
||||||
userRouterGroupChild := mw.NewRouterGroup(userRouterGroup, "")
|
userRouterGroupChild := mw.NewRouterGroup(userRouterGroup, "")
|
||||||
userRouterGroupChildToken := mw.NewRouterGroup(userRouterGroup, "", mw.WithGinParseToken(rdb))
|
userRouterGroupChildToken := mw.NewRouterGroup(userRouterGroup, "", mw.WithGinParseToken(rdb))
|
||||||
userRouterGroupChild.POST("/user_register", u.UserRegister)
|
userRouterGroupChild.POST("/user_register", u.UserRegister)
|
||||||
@ -52,7 +52,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
//friend routing group
|
//friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
friendRouterGroup := r.Group("/friend")
|
||||||
{
|
{
|
||||||
f := NewFriend(zk)
|
f := NewFriend(discov)
|
||||||
friendRouterGroup.Use(mw.GinParseToken(rdb))
|
friendRouterGroup.Use(mw.GinParseToken(rdb))
|
||||||
friendRouterGroup.POST("/delete_friend", f.DeleteFriend) //1
|
friendRouterGroup.POST("/delete_friend", f.DeleteFriend) //1
|
||||||
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList) //1
|
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList) //1
|
||||||
@ -67,7 +67,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
friendRouterGroup.POST("/import_friend", f.ImportFriends) //1
|
friendRouterGroup.POST("/import_friend", f.ImportFriends) //1
|
||||||
friendRouterGroup.POST("/is_friend", f.IsFriend) //1
|
friendRouterGroup.POST("/is_friend", f.IsFriend) //1
|
||||||
}
|
}
|
||||||
g := NewGroup(zk)
|
g := NewGroup(discov)
|
||||||
groupRouterGroup := r.Group("/group")
|
groupRouterGroup := r.Group("/group")
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
////certificate
|
////certificate
|
||||||
authRouterGroup := r.Group("/auth")
|
authRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
a := NewAuth(zk)
|
a := NewAuth(discov)
|
||||||
u := NewUser(zk)
|
u := NewUser(discov)
|
||||||
authRouterGroupChild := mw.NewRouterGroup(authRouterGroup, "")
|
authRouterGroupChild := mw.NewRouterGroup(authRouterGroup, "")
|
||||||
authRouterGroupChildToken := mw.NewRouterGroup(authRouterGroup, "", mw.WithGinParseToken(rdb))
|
authRouterGroupChildToken := mw.NewRouterGroup(authRouterGroup, "", mw.WithGinParseToken(rdb))
|
||||||
authRouterGroupChild.POST("/user_register", u.UserRegister) //1
|
authRouterGroupChild.POST("/user_register", u.UserRegister) //1
|
||||||
@ -117,7 +117,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
////Third service
|
////Third service
|
||||||
thirdGroup := r.Group("/third")
|
thirdGroup := r.Group("/third")
|
||||||
{
|
{
|
||||||
t := NewThird(zk)
|
t := NewThird(discov)
|
||||||
thirdGroup.Use(mw.GinParseToken(rdb))
|
thirdGroup.Use(mw.GinParseToken(rdb))
|
||||||
thirdGroup.POST("/get_rtc_invitation_info", t.GetSignalInvitationInfo)
|
thirdGroup.POST("/get_rtc_invitation_info", t.GetSignalInvitationInfo)
|
||||||
thirdGroup.POST("/get_rtc_invitation_start_app", t.GetSignalInvitationInfoStartApp)
|
thirdGroup.POST("/get_rtc_invitation_start_app", t.GetSignalInvitationInfoStartApp)
|
||||||
@ -134,7 +134,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
////Message
|
////Message
|
||||||
msgGroup := r.Group("/msg")
|
msgGroup := r.Group("/msg")
|
||||||
{
|
{
|
||||||
m := NewMsg(zk)
|
m := NewMsg(discov)
|
||||||
msgGroup.Use(mw.GinParseToken(rdb))
|
msgGroup.Use(mw.GinParseToken(rdb))
|
||||||
msgGroup.POST("/newest_seq", m.GetSeq)
|
msgGroup.POST("/newest_seq", m.GetSeq)
|
||||||
msgGroup.POST("/send_msg", m.SendMessage)
|
msgGroup.POST("/send_msg", m.SendMessage)
|
||||||
@ -158,7 +158,7 @@ func NewGinRouter(zk discoveryregistry.SvcDiscoveryRegistry, rdb redis.Universal
|
|||||||
////Conversation
|
////Conversation
|
||||||
conversationGroup := r.Group("/conversation")
|
conversationGroup := r.Group("/conversation")
|
||||||
{
|
{
|
||||||
c := NewConversation(zk)
|
c := NewConversation(discov)
|
||||||
conversationGroup.Use(mw.GinParseToken(rdb))
|
conversationGroup.Use(mw.GinParseToken(rdb))
|
||||||
conversationGroup.POST("/get_all_conversations", c.GetAllConversations)
|
conversationGroup.POST("/get_all_conversations", c.GetAllConversations)
|
||||||
conversationGroup.POST("/get_conversation", c.GetConversation)
|
conversationGroup.POST("/get_conversation", c.GetConversation)
|
||||||
|
@ -28,12 +28,14 @@ func Call[A, B, C any](
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.ZDebug(c, "gin bind json success", "req", req)
|
||||||
cli, err := client(c)
|
cli, err := client(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "get conn error", err, "req", req)
|
log.ZError(c, "get conn error", err, "req", req)
|
||||||
apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
|
apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.ZDebug(c, "get conn success", "req", req)
|
||||||
data, err := rpc(cli, c, &req)
|
data, err := rpc(cli, c, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err) // RPC调用失败
|
apiresp.GinError(c, err) // RPC调用失败
|
||||||
|
Loading…
x
Reference in New Issue
Block a user