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

27 lines
531 B
Go

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