From dbe76eb4f78a74a6a3739706cf2e121262ac4c22 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 10 Dec 2024 20:10:02 +0800 Subject: [PATCH] grpcgateway --- server/v2/api/grpcgateway/server.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/v2/api/grpcgateway/server.go b/server/v2/api/grpcgateway/server.go index 16a622a94961..977eb369c894 100644 --- a/server/v2/api/grpcgateway/server.go +++ b/server/v2/api/grpcgateway/server.go @@ -75,7 +75,13 @@ func New[T transaction.Tx]( s.logger = logger.With(log.ModuleKey, s.Name()) s.config = serverCfg + mux := http.NewServeMux() + mux.Handle("/", s.GRPCGatewayRouter) + s.server = &http.Server{ + Addr: s.config.Address, + Handler: mux, + } return s, nil } @@ -110,14 +116,6 @@ func (s *Server[T]) Start(ctx context.Context) error { return nil } - mux := http.NewServeMux() - mux.Handle("/", s.GRPCGatewayRouter) - - s.server = &http.Server{ - Addr: s.config.Address, - Handler: mux, - } - s.logger.Info("starting gRPC-Gateway server...", "address", s.config.Address) if err := s.server.ListenAndServe(); err != nil && err != http.ErrServerClosed { return fmt.Errorf("failed to start gRPC-Gateway server: %w", err)