package main import ( "context" "dashoo.cn/micro/app/handler/base" "dashoo.cn/micro/app/handler/cust" "dashoo.cn/opms_libary/micro_srv" "github.com/gogf/gf/frame/g" "github.com/smallnest/rpcx/protocol" ) func main() { srvAddr := g.Config().GetString("setting.bind-addr") basePath := g.Config().GetString("setting.srv-name") // 创建总服务包 s := micro_srv.CreateAndInitService(basePath) s.RegisterName("Product", new(base.ProductHandler), "") s.RegisterName("Distributor", new(base.DistributorHandler), "") s.RegisterName("District", new(base.DistrictHandler), "") s.RegisterName("Region", new(base.RegionHandler), "") s.RegisterName("Customer", new(cust.CustomerHeader), "") s.RegisterName("Contant", new(cust.CustomerContantHeader), "") s.RegisterName("Belong", new(cust.CustBelongHeader), "") // 注册服务对象 //s.RegisterName("Auth", new(handler.Auth), "") // 注册文件处理Service对象 //dynamic.BeanFactory.BeanRegister(service.NewRoleService()) // 注册auth处理 s.AuthFunc = handleAuth // 运行服务 if err := s.Serve("tcp", srvAddr); err != nil { g.Log().Fatal(err) } } // AuthExcludePaths 设定不需要认证的路径 var AuthExcludePaths = []string{ "/Auth/Login", "/Role/GetRoleList", "/Common/GetCaptchaImg", "/Model/*", "/Organize/GetOrgTreeList", "/User/SendResetPasswordEmail", "/User/ResetPasswordFromEmail", } // 处理Auth func handleAuth(ctx context.Context, req *protocol.Message, token string) error { return micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths) }