Commit faf23f43 by Li Feifei

优化代码

parent 9b3c1fbf
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"im-microservice/sevice/health" "im-microservice/sevice/health"
"im-microservice/sevice/im_chat_room" "im-microservice/sevice/im_chat_room"
"im-microservice/sevice/im_friend_request" "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" ic "im-microservice/sevice/im_configure"
"im-microservice/sevice/im_user" "im-microservice/sevice/im_user"
iur "im-microservice/sevice/im_user_relationship" iur "im-microservice/sevice/im_user_relationship"
...@@ -45,8 +45,7 @@ func init() { ...@@ -45,8 +45,7 @@ func init() {
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer( grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
middleware.Interceptor, middleware.Interceptor,
grpc_validator.UnaryServerInterceptor(), grpc_validator.UnaryServerInterceptor(),
middleware.Interceptor, middleware.Auth,
//middleware.Auth,
grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()), grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()),
grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()), grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()),
))) )))
...@@ -57,7 +56,7 @@ func init() { ...@@ -57,7 +56,7 @@ func init() {
pb.RegisterImUserServer(rpc_server, &im_user.ImUserServer{}) pb.RegisterImUserServer(rpc_server, &im_user.ImUserServer{})
pb.RegisterUserRelationshipServiceServer(rpc_server, &iur.UserRelationshipService{}) pb.RegisterUserRelationshipServiceServer(rpc_server, &iur.UserRelationshipService{})
pb.RegisterImFriendServiceServer(rpc_server, &im_friend_request.ImFriendService{}) 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) reflection.Register(rpc_server)
RpcServer = rpc_server RpcServer = rpc_server
......
...@@ -56,23 +56,12 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...@@ -56,23 +56,12 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
if info.FullMethod != health_path { if info.FullMethod != health_path {
request_map := make(map[string]string) request_map := make(map[string]string)
s := fmt.Sprintf("%v", req) key_r, _ := regexp.Compile(`[^}|^Common:]\s?(.*?):"(.*?)"`)
key_r, _ := regexp.Compile(`Appkey:"(.*?)"`) result := key_r.FindAllStringSubmatch( fmt.Sprintf("%v", req), -1)
nonce_r, _ := regexp.Compile(`Nonce:"(.*?)"`) for _, v := range result {
c_r, _ := regexp.Compile(`Curtime:"(.*?)"`) request_map[v[1]] = v[2]
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]
if err := checksum(request_map); err != nil { if err := checksum(request_map); err != nil {
return nil, err 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