package main import ( "context" "fmt" "git.sch9.ru/new_gate/ms-auth/config" userv1gw "git.sch9.ru/new_gate/ms-auth/proto/user/v1" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/ilyakaznacheev/cleanenv" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "net/http" "os" "os/signal" "syscall" ) func main() { var cfg config.Config err := cleanenv.ReadConfig(".env", &cfg) if err != nil { panic(fmt.Sprintf("error reading config: %s", err.Error())) } ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() mux := runtime.NewServeMux() opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} err = userv1gw.RegisterUserServiceHandlerFromEndpoint(ctx, mux, cfg.Address, opts) if err != nil { panic(err) } go func() { err = http.ListenAndServe(cfg.ProxyAddress, mux) if err != nil { panic(err) } }() fmt.Println("server proxy started") stop := make(chan os.Signal, 1) signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT) <-stop return }