Commit faf23f43 by Li Feifei

优化代码

parent 9b3c1fbf
......@@ -8,7 +8,7 @@ import (
"im-microservice/sevice/health"
"im-microservice/sevice/im_chat_room"
"im-microservice/sevice/im_friend_request"
"im-microservice/sevice/im_chat_room_user"
//"im-microservice/sevice/im_chat_room_user"
ic "im-microservice/sevice/im_configure"
"im-microservice/sevice/im_user"
iur "im-microservice/sevice/im_user_relationship"
......@@ -45,8 +45,7 @@ func init() {
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
middleware.Interceptor,
grpc_validator.UnaryServerInterceptor(),
middleware.Interceptor,
//middleware.Auth,
middleware.Auth,
grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()),
grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()),
)))
......@@ -57,7 +56,7 @@ func init() {
pb.RegisterImUserServer(rpc_server, &im_user.ImUserServer{})
pb.RegisterUserRelationshipServiceServer(rpc_server, &iur.UserRelationshipService{})
pb.RegisterImFriendServiceServer(rpc_server, &im_friend_request.ImFriendService{})
pb.RegisterChatRoomUserServer(rpc_server, &im_chat_room_user.ChatRoomUserServer{})
//pb.RegisterChatRoomUserServer(rpc_server, &im_chat_room_user.ChatRoomUserServer{})
reflection.Register(rpc_server)
RpcServer = rpc_server
......
......@@ -56,23 +56,12 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
if info.FullMethod != health_path {
request_map := make(map[string]string)
s := fmt.Sprintf("%v", req)
key_r, _ := regexp.Compile(`[^}|^Common:]\s?(.*?):"(.*?)"`)
key_r, _ := regexp.Compile(`Appkey:"(.*?)"`)
nonce_r, _ := regexp.Compile(`Nonce:"(.*?)"`)
c_r, _ := regexp.Compile(`Curtime:"(.*?)"`)
cs_r, _ := regexp.Compile(`Checksum:"(.*?)"`)
appkey := key_r.FindAllStringSubmatch(s, -1)
nonce := nonce_r.FindAllStringSubmatch(s, -1)
curtime := c_r.FindAllStringSubmatch(s, -1)
check_sum := cs_r.FindAllStringSubmatch(s, -1)
request_map["Appkey"] = appkey[0][1]
request_map["Nonce"] = nonce[0][1]
request_map["Curtime"] = curtime[0][1]
request_map["Checksum"] = check_sum[0][1]
result := key_r.FindAllStringSubmatch( fmt.Sprintf("%v", req), -1)
for _, v := range result {
request_map[v[1]] = v[2]
}
if err := checksum(request_map); err != nil {
return nil, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment