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

26 lines
573 B
Go

package handlers
import (
"go-server/internal/service"
"net/http"
"github.com/gin-gonic/gin"
)
type CategoryController struct {
categoryService *service.CategoryService
}
func NewCategoryController(categoryService *service.CategoryService) *CategoryController {
return &CategoryController{categoryService: categoryService}
}
func (h *CategoryController) GetAll(c *gin.Context) {
categories, err := h.categoryService.GetAll(c)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, categories)
}