This commit is contained in:
2025-11-03 00:48:16 +01:00
parent ed18be9fbd
commit eb2c8fea64
7 changed files with 229 additions and 6 deletions

View File

@@ -0,0 +1,25 @@
package handlers
import (
"go_oxspeak_server/models"
"github.com/gin-gonic/gin"
)
type ChannelHandler struct {
*Handler
}
func AddChannelRoutes(rg *gin.RouterGroup, h *Handler) {
channel := rg.Group("/channel")
handler := &ChannelHandler{h}
channel.GET("/:id", handler.getChannels)
}
func (h *Handler) getChannels(c *gin.Context) {
var users []models.User
h.DB.Find(&users)
}

View File

@@ -0,0 +1,31 @@
package handlers
import (
"go_oxspeak_server/database"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type Handler struct {
DB *gorm.DB
}
func CreateRouter() *gin.Engine {
router := gin.Default()
handler := &Handler{DB: database.DB}
api := router.Group("/api")
{
AddChannelRoutes(api, handler)
}
router.GET("/health", handler.healthcheck)
return router
}
func (h *Handler) healthcheck(c *gin.Context) {
c.JSON(200, gin.H{"status": "ok"})
}

View File

@@ -0,0 +1 @@
package handlers