Files
music-index/api/handlers/artist_handler.go
T
2026-03-13 22:23:42 +01:00

34 lines
718 B
Go

package handlers
import (
"net/http"
"zardzul/music-index/repository"
"github.com/gin-gonic/gin"
)
type ArtistHandler struct {
repo repository.ArtistRepository
}
func NewArtistHandler(repo repository.ArtistRepository) *ArtistHandler {
return &ArtistHandler{repo: repo}
}
// GetAll godoc
// @Summary List all artists
// @Tags artist
// @Produce json
// @Success 200 {array} map[string]interface{}
// @Failure 500 {object} ErrorResponse
// @Router /artists [get]
func (handler *ArtistHandler) GetAll(c *gin.Context) {
artists, err := handler.repo.GetAll(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, artists)
}