浏览代码

refactor: simplify handler management by changing pointer receiver to value type

lblt 2 周之前
父节点
当前提交
960aadf65b
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      pkg/server/gin.go

+ 3 - 3
pkg/server/gin.go

@@ -16,7 +16,7 @@ type Server struct {
 	router   *gin.Engine
 	logger   *logrus.Logger
 	config   *Config
-	handlers []*ServiceHandler
+	handlers []ServiceHandler
 }
 
 func NewGinServer(logger *logrus.Logger, config *Config) (*Server, error) {
@@ -61,7 +61,7 @@ func (s *Server) Close() error {
 	return nil
 }
 
-func (s *Server) AddHandler(h *ServiceHandler) {
+func (s *Server) AddHandler(h ServiceHandler) {
 	s.handlers = append(s.handlers, h)
 }
 
@@ -76,7 +76,7 @@ func (s *Server) SetupRoutes() {
 			s.logger.Error("nil handler found")
 			continue
 		}
-		(*h).SetupRoutes(s.router)
+		h.SetupRoutes(s.router)
 	}
 }