Files
futur-web-app/server/internal/handlers/supplement_handler.go
2025-11-03 12:24:01 +02:00

36 lines
834 B
Go

package handlers
import (
"net/http"
"go-server/internal/service"
"github.com/gin-gonic/gin"
)
type SupplementController struct {
service *service.SupplementService
}
func NewSupplementController(service *service.SupplementService) *SupplementController {
return &SupplementController{service}
}
func (c *SupplementController) GetAll(ctx *gin.Context) {
supplements, err := c.service.GetAll(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
ctx.JSON(http.StatusOK, supplements)
}
func (c *SupplementController) GetDailySupplementsOverview(ctx *gin.Context) {
supplements, err := c.service.GetDailySupplementsOverview(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
ctx.JSON(http.StatusOK, supplements)
}