Files
kontor/kontor-gin/internal/handlers/publisher.go
T

24 lines
501 B
Go

package handlers
import (
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-gonic/gin"
)
type PublisherHandler struct {
Service *service.PublisherService
}
func (handler *PublisherHandler) List(c *gin.Context) {
comics, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertPublishersToDtos(comics)
c.JSON(http.StatusOK, dtos)
}