From a9485516b68c16f9c83b2875c7230de6d7ca3836 Mon Sep 17 00:00:00 2001 From: novikovmu Date: Wed, 5 Oct 2022 11:34:10 +0300 Subject: [PATCH] MSP-1068 init routes --- routes/routes.go | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 routes/routes.go diff --git a/routes/routes.go b/routes/routes.go new file mode 100644 index 0000000..eaeb563 --- /dev/null +++ b/routes/routes.go @@ -0,0 +1,86 @@ +package routes + +import ( + "github.com/integration-system/isp-kit/cluster" + "github.com/integration-system/isp-kit/grpc" + "github.com/integration-system/isp-kit/grpc/endpoint" + "github.com/integration-system/isp-kit/grpc/isp" + "msp-admin-service/controller" +) + +type Controllers struct { + Auth controller.Auth + User controller.User + Customization controller.Customization +} + +func EndpointDescriptors() []cluster.EndpointDescriptor { + return endpointDescriptors(Controllers{}) +} + +func Handler(wrapper endpoint.Wrapper, c Controllers) isp.BackendServiceServer { + muxer := grpc.NewMux() + for _, descriptor := range endpointDescriptors(c) { + muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler)) + } + return muxer +} + +func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor { + return []cluster.EndpointDescriptor{ + { + Path: "admin/auth/login", + Inner: false, + UserAuthRequired: false, + Handler: c.Auth.Login, + }, + { + Path: "admin/auth/login_with_sudir", + Inner: false, + UserAuthRequired: false, + Handler: c.Auth.LoginWithSudir, + }, + { + Path: "admin/auth/logout", + Inner: true, + UserAuthRequired: false, + Handler: c.Auth.Logout, + }, + { + Path: "admin/user/get_profile", + Inner: true, + UserAuthRequired: false, + Handler: c.User.GetProfile, + }, + { + Path: "admin/user/get_design", + Inner: true, + UserAuthRequired: false, + Handler: c.Customization.GetUIDesign, + }, + { + Path: "admin/user/get_users", + Inner: true, + UserAuthRequired: false, + Handler: c.User.GetUsers, + }, + { + Path: "admin/user/create_user", + Inner: true, + UserAuthRequired: false, + Handler: c.User.CreateUser, + }, + { + Path: "admin/user/update_user", + Inner: true, + UserAuthRequired: false, + Handler: c.User.UpdateUser, + }, + { + Path: "admin/user/delete_user", + Inner: true, + UserAuthRequired: false, + Handler: c.User.DeleteUser, + }, + } +}