34 lines
724 B
Go
34 lines
724 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 /artist/getAll [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)
|
|
}
|