updates
This commit is contained in:
26
server/internal/handlers/nutrient_handler.go
Normal file
26
server/internal/handlers/nutrient_handler.go
Normal file
@@ -0,0 +1,26 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user