package server import ( "io" "net/http" "github.com/gin-gonic/gin" ) func (s *Server) RegisterRoutes() http.Handler { r := gin.Default() // Content r.GET("/", s.HelloWorldHandler) // Auth r.POST("/login", s.LoginHandler) r.POST("/register", s.LoginHandler) // Monitoring r.GET("/health", s.healthHandler) return r } func (s *Server) HelloWorldHandler(c *gin.Context) { resp := make(map[string]string) resp["message"] = "Hello World" c.JSON(http.StatusOK, resp) } func (s *Server) healthHandler(c *gin.Context) { c.JSON(http.StatusOK, s.db.Health()) } func (s *Server) LoginHandler(c *gin.Context) { _, err := io.ReadAll(c.Request.Body) if err != nil { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{ "error": "VALIDATEERR-1", "message": "Invalid inputs. Please check your inputs"}) } // err = client.Set("id", jsonData, 0).Err() c.JSON(http.StatusOK, s.db.Health()) }